Loading...
Loading...
Professional LaTeX figure and table positioning. Handle float placement, subfigure/subtable layouts, side-by-side arrangements, and cross-column figures. Does NOT adjust sizes, widths, or scaling.
npx skill4agent add dw-dengwei/skills latex-figure-table-layout[h][t][b][p]figure*table*| Parameter | Meaning | Priority |
|---|---|---|
| Here (exact location) | Highest |
| Top of page | Medium |
| Bottom of page | Medium |
| Separate float page | Lowest |
| Override LaTeX defaults | - |
\begin{figure}[htbp] % Recommended: try here, then top, bottom, then float page
\end{figure}\begin{figure}[!htbp] % Force LaTeX to respect your order
\end{figure}[htbp][!htbp][h]\usepackage{subcaption}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{figure1.pdf}
\caption{First figure}
\label{fig:first}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\filename]{figure2.pdf}
\caption{Second figure}
\label{fig:second}
\end{subfigure}
\caption{Main caption for both figures}
\label{fig:both}
\end{figure}\begin{figure}[htbp]
\centering
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\filename]{fig1.pdf}
\caption{Caption A}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\filename]{fig2.pdf}
\caption{Caption B}
\end{bmatrix}
\\
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\filename]{fig3.pdf}
\caption{Caption C}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\filename]{fig4.pdf}
\caption{Caption D}
\end{subfigure}
\caption{Main caption for all four}
\label{fig:grid}
\end{figure}\begin{table}[htbp]
\centering
\begin{subtable}[t]{0.45\textwidth}
\centering
\begin{tabular}{cc}
\toprule
A & B \\
\midrule
1 & 2 \\
\bottomrule
\end{tabular}
\caption{First table}
\label{tab:first}
\end{subtable}
\hfill
\begin{subtable}[t]{0.45\textwidth}
\centering
\begin{tabular}{cc}
\toprule
C & D \\
\midrule
3 & 4 \\
\bottomrule
\end{tabular}
\caption{Second table}
\label{tab:second}
\end{subtable}
\caption{Main caption}
\label{tab:both}
\end{table}\begin{figure}[htbp]
\centering
\begin{minipage}[c]{0.45\textwidth}
\centering
\includegraphics[width=\filename]{figure.pdf}
\caption{My figure}
\label{fig:minipage}
\end{minipage}
\hfill
\begin{minipage}[c]{0.45\textwidth}
\centering
\begin{tabular}{lc}
\toprule
Method & Acc \\
\midrule
A & 85.2 \\
B & 92.1 \\
\bottomrule
\end{tabular}
\caption{My table}
\label{tab:minipage}
\end{minipage}
\caption{Combined figure and table}
\label{fig+tab}
\end{figure}\begin{figure}[htbp]
\centering
\subcaptionbox{Figure label\label{fig:subcap}}
{\includegraphics[width=0.45\textwidth]{figure.pdf}}
\qquad
\subcaptionbox{Table label\label{tab:subcap}}
{\begin{tabular}{lc}
\toprule
A & B \\
\midrule
1 & 2 \\
\bottomrule
\end{tabular}}
\caption{Combined caption}
\label{fig:subcap:combined}
\end{figure}\begin{figure*}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{wide-figure.pdf}
\caption{Wide figure spanning both columns}
\label{fig:wide}
\end{figure*}\begin{table*}[htbp]
\centering
\begin{tabular}{lcccc}
\toprule
Method & A & B & C & D \\
\midrule
Baseline & 85.2 & 86.1 & 87.3 & 88.0 \\
Ours & \textbf{92.1} & \textbf{91.5} & \textbf{93.2} & \textbf{94.1} \\
\bottomrule
\end{tabular}
\caption{Wide table spanning both columns}
\label{tab:wide}
\end{table*}[h]% Before (problematic)
\begin{figure}[h]
% After (recommended)
\begin{figure}[htbp]
% Or force placement
\begin{figure}[!htbp][p]% Add stretch to push other content
\begin{figure}[htbp]
\centering
\includegraphics[width=0.7\textwidth]{figure.pdf}
\caption{Caption}
% Add space to encourage text to flow around
\end{figure}[!htbp]\FloatBarrierplaceins\usepackage{placeins}
\section{My Section}
Text reference to \figurename~\ref{fig:myfig}.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{figure.pdf}
\caption{My figure}
\label{fig:myfig}
\end{figure}
\FloatBarrier % Prevents floats from crossing this barrier% Use [t], [b], or [c] for vertical alignment
\begin{subfigure}[t]{0.45\textwidth} % [t] = top alignment
\begin{subfigure}[b]{0.45\textwidth} % [b] = bottom alignment\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\filename]{fig.pdf}
\caption{Caption text}
\end{subfigure}[htbp][!htbp]booktabssubcaptionsubfig\FloatBarrier\usepackage{subcaption} % For subfigure/subtable
\usepackage{booktabs} % For professional tables (not positioning)
\usepackage{placeins} % For \FloatBarrier| Request | Approach |
|---|---|
| "Figure 1 always goes to next page" | Change |
| "Arrange 4 figures in 2x2 grid" | Use subfigure with line break |
| "Put figure and table side by side" | Use minipage or subcaptionbox |
| "Figure 2 is far from Section 2.2" | Use |
| "Wide table spans both columns" | Use |