Skip to content

C5. The paper ​

Goal: a LaTeX paper whose figures foresight wrote, included as they are.

latex
% The example paper of foresight's path C (docs/manual/paths/c-paper): four figures written by foresight, included
% as they are, at their size, and two LaTeX pictures (cairolatex) whose labels LaTeX sets. Built by
% scripts/build_paper.sh (Tectonic, or LuaLaTeX); its figures are the files the docs examples write
% (docs/public/examples).
\documentclass[10pt,twocolumn]{article}
\usepackage[a4paper,margin=1.6cm,columnsep=0.6cm]{geometry}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{color}
\usepackage{amsmath}
\graphicspath{{../../public/examples/}}

\title{A damped oscillator, plotted from Fortran}
\author{foresight's path C}
\date{}

\begin{document}
\maketitle

\section{Introduction}
The figures of this paper are PDF files written by foresight, a Fortran library and command line that reads gnuplot
scripts. Each is included at its own size: a column is 8.5\,cm wide, the page 17.8\,cm, so neither the texts nor the
lines of a figure are scaled by \LaTeX{}. Their fonts are embedded in them, Liberation Sans and Latin Modern Roman.

\section{The response}
A damped oscillator answers a step with the oscillation of Figure~\ref{fig:paper}, decaying within its envelope
$e^{-t/\tau}$. Figure~\ref{fig:sizes} is the same set of curves at gnuplot's defaults made into a column figure by
\texttt{set terminal pdfcairo size single theme paper}.

\begin{figure}[t]
  \centering
  \includegraphics{cb_paper}
  \caption{A column figure: \texttt{theme paper}, 8\,pt texts, 0.75\,pt lines.}
  \label{fig:paper}
\end{figure}

\begin{figure}[t]
  \centering
  \includegraphics{pc03}
  \caption{The column size, \texttt{size single}: 8.5 by 6\,cm.}
  \label{fig:sizes}
\end{figure}

\section{Frequency response}
The gain $|H(i\omega)| = 1/\sqrt{(1 - \omega^2)^2 + (2 \zeta \omega)^2}$ peaks near the natural frequency for small
damping ratios $\zeta$ (Figures~\ref{fig:double} and~\ref{fig:panels}); the phase turns by half a period across it.

\begin{figure*}[t]
  \centering
  \includegraphics{cb_paper_double}
  \caption{Two panels across the page, in Latin Modern Roman: \texttt{size double theme paper serif}.}
  \label{fig:double}
\end{figure*}

\begin{figure*}[t]
  \centering
  \includegraphics{pc04}
  \caption{Three panels of a multiplot layout under its title.}
  \label{fig:panels}
\end{figure*}

\section{Labels set by \LaTeX{}}
A figure's labels can also be set by \LaTeX{} itself, in the paper's fonts and with its math: foresight's
\texttt{set terminal cairolatex} writes the drawing as a PDF and the labels as a \LaTeX{} picture, as gnuplot's
cairolatex does, which the paper includes by \verb|\input|. In Figure~\ref{fig:latex-response} the axis labels
$t/\tau$ and $x/x_0$ and the key are set in Latin Modern, as this text; in Figure~\ref{fig:latex-gain} the damping
ratio $\zeta$ of each curve.

\begin{figure}[t]
  \centering
  \input{../../public/examples/pc06.tex}
  \caption{The response, its labels set by \LaTeX{}: \texttt{set terminal cairolatex pdf size single}.}
  \label{fig:latex-response}
\end{figure}

\begin{figure}[t]
  \centering
  \input{../../public/examples/cb_latex.tex}
  \caption{The gain $|H(i\omega)|$ for three damping ratios, on a logarithmic axis.}
  \label{fig:latex-gain}
\end{figure}

\section{Conclusion}
A figure made for its column needs nothing but \verb|\includegraphics|, or \verb|\input| for one whose labels
\LaTeX{} sets: no scaling, no converter, its fonts travel with it.

\end{document}

paper.pdf is that source compiled: four figures of the previous chapters, two in a column, two across the page, and two figures whose labels LaTeX sets (C6), included by \input.

console
$ bash scripts/docs_examples.sh     # the figures, docs/public/examples/*.pdf
$ bash scripts/build_paper.sh docs/public/paper/paper.pdf
build_paper: docs/public/paper/paper.pdf (lualatex, 2 pages, 17 fonts, all embedded)

Why it works ​

  • Each figure is made at its final size (size single, size double): \includegraphics{cb_paper} takes it without width=, so its 8 pt texts stay 8 pt, as the captions around it.
  • The figures' fonts are embedded (Type 3 fonts of their glyphs): the paper's PDF holds every font it shows, as a journal's checker asks. scripts/build_paper.sh checks it with pdffonts, and checks the log for any warning about the figures.
  • theme paper serif sets the figure texts in Latin Modern Roman, the paper's own font.

Try this ​

  • \usepackage{lmodern} out, \usepackage{mathptmx} in (Times): then theme paper (sans) suits the figures better than serif.
  • Build it with Tectonic (tectonic paper.tex): the CI does (.github/workflows/paper.yml).

Pitfalls ​

  • A figure wider than its column (a 600 px figure is 15.9 cm) overflows it: make it with size single, or put it in a figure*.
  • The paper finds the figures through \graphicspath: build it where docs/public/examples is next to it, as build_paper.sh does.

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.