Ron Bakker/LabTeXHelp
← Back to LabTeX

Guide

Figures and tables

A LabTeX figure is usually code: a few lines of MathLab that draw a plot. It is drawn live while you write, typeset in the journal’s figure style, and exported as image files plus the code that made them.

MathLab figures

Press Figure in the toolbar. A figure appears with example code and its editor open; change the code and the plot is redrawn. Any MathLab function works — plot, surf, contourf, histogram, ode45 and the rest.

The caption is the text under the figure. Click the dashed “Click to write the figure caption…” line (or anywhere on the caption line) and type; when you press Done in the code editor of a figure without a caption, the cursor goes there for you. The number in front — “Figure 1:” or “Fig. 1.” — is added automatically.

\begin{figure}
  \begin{mathlab}[aspect=0.55]
    t = linspace(0, 20, 600);
    for z = [0.05 0.2 0.5]
      plot(t, exp(-z*t) .* cos(sqrt(1 - z^2)*t), 'LineWidth', 1.4, 'DisplayName', sprintf('ζ = %.2f', z))
      hold on
    end
    hold off, legend show, grid on
    xlabel('time t'), ylabel('x(t)')
  \end{mathlab}
  \caption{Free response for three damping ratios.}\label{fig:free}
\end{figure}
Typesetting…

Shape, width and time

Figure styles

Figures follow the layout: the IEEE-like layout draws them with MathLab’s style('ieee') (Times, small type, colour-blind-safe lines), the journal layout with style('nature'), the others with style('paper'). Put a style(…) call in the code to choose another. See MathLab’s figure guide for the styles.

Images

Insert → Image figure takes the address of a PNG, JPG or SVG on the web. In the LaTeX export it becomes \includegraphics with the file name; put the file next to main.tex and it is included.

Placement

On the compiled pages figures and tables float like in LaTeX: when one does not fit in the rest of the column, the text carries on and the figure goes to the top of the next column or page. Full-width figures go to the top of the next page. In the LaTeX export figures get [tb] placement.

Tables

Press Table. Click a cell to type; Tab moves to the next cell and adds a row at the end. While the cursor is in the table, a toolbar under it adds and removes rows and columns, sets the header row, the column alignment (one letter per column: l, c, r), full width and the label. Cells can hold formulas, citations and references. Captions go above tables, as journals expect.

\begin{table}
  \caption{Resonance properties of the driven oscillator}\label{tab:res}
  \begin{tabular}{cccc}
    \toprule
    $\zeta$ & $r_\mathrm{peak}$ & peak $Xk/F_0$ & $Q$ \\
    \midrule
    0.1 & 0.990 & 5.03 & 5.0 \\
    0.2 & 0.959 & 2.55 & 2.5 \\
    0.4 & 0.825 & 1.36 & 1.25 \\
    \bottomrule
  \end{tabular}
\end{table}
Typesetting…