1

I am working on a LaTeX document where I have a main document and supplementary information (SI). In the SI, I want to maintain the sequence "Figure S1, Figure S2..." for labeling the figures. In the main document, I want to reference these figures from the SI using the \ref{} command, but I'm encountering some issues.

Here's a simplified version of my setup:

main.tex:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\section{Main Document}

\begin{figure}[htbp] \centering \includegraphics[width=0.5\textwidth]{example-image-a} \caption{Example A} \label{fig:example_a} \end{figure}

\begin{figure}[htbp] \centering \includegraphics[width=0.5\textwidth]{example-image-b} \caption{Example B} \label{fig:example_b} \end{figure}

Text in the main document attempting to call the figures from the Supplementary Information: Figure \ref{fig:example_c} and Figure \ref{fig:example_d}.

\end{document}

support_information.tex:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\section{Supplementary Information}

\begin{figure}[htbp] \centering \includegraphics[width=0.5\textwidth]{example-image-c} \caption{Example C} \label{fig:example_c} \end{figure}

\end{document}

It is crucial that the sequence in both documents be distinct: 'Figure 1', 'Figure 2',... for the main document and 'Figure S1', 'Figure S2',... for the Supplementary Information.

2 Answers2

1

This uses \include and \includeonly to combine both files, but only print one at a time.

\documentclass{article}
\usepackage{graphicx}

\includeonly{test5,test6}% print both

\begin{document} \include{test6}% main text

\setcounter{page}{1} \setcounter{section}{0} \setcounter{figure}{0} \renewcommand{\thefigure}{S\arabic{figure}} \renewcommand{\thepage}{S\arabic{page}}

\include{test5}% supplemental \end{document}

Stored as test6.tex:

\section{Main Document}

\begin{figure}[htbp] \centering \includegraphics[width=0.5\textwidth]{example-image-a} \caption{Example A} \label{fig:example_a} \end{figure}

\begin{figure}[htbp] \centering \includegraphics[width=0.5\textwidth]{example-image-b} \caption{Example B} \label{fig:example_b} \end{figure}

Text in the main document attempting to call the figures from the Supplementary Information: Figure \ref{fig:example_c}.

Stored as test5.tex

\section{Supplementary Information}

\begin{figure}[htbp] \centering \includegraphics[width=0.5\textwidth]{example-image-c} \caption{Example C} \label{fig:example_c} \end{figure}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
-1

Two answers that could help

  1. Change the figure captions

Change numbering of captions in figures

  1. Use references from other documents

Cross-referencing between different files

Xexeo
  • 300