1

I am creating standalone documents for Frontiers as it wants tables in a separate file. However, I cannot keep numeration (for example, table 3 in the document, it is Table 1 in this file). Do you know how I can keep numeration as in label?

\documentclass[utf8]{frontiersHLTH} % for Health articles

\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{url,hyperref,lineno,microtype,subcaption}
\linenumbers

\usepackage{makecell}


\begin{document}

\def\keyFont{\fontsize{8}{11}\helveticabold }
\def\firstAuthorLast{Sample} 
\def\Authors{}


%%%TABLE%%%
{\renewcommand{\arraystretch}{1.5}
\begin{table}[!htbp]
\begin{tabular}{ cccccc } 
\hline
& c1 & c2 & c3 & c4 c5 & c6 & c7 \\
\hline
Example 1 & 12 & 32 & 12 & 43 & 12 \\ 
Example 2 & 12 & 21 & 41 & 43 & 21\\  
\hline
\end{tabular}
\caption{\label{tab:x1} \small Example of caption}
\end{table}
}

\end{document}

Here the template (if you need it): https://it.overleaf.com/latex/templates/template-for-frontiers-journal/myxxkvjwqhrv

1 Answer 1

2

With overleaf, this is what I use to crossreference object between subfiles. Define the following command in your preambles :

\newcommand*{\myexternaldocument}[1]{%
    \externaldocument{#1}%
    \addFileDependency{#1.tex}%
    \addFileDependency{#1.aux}%
}

And if in file1, you need to crossref an element from file2, just add in your preamble :

\myexternaldocument{file2}

In Overleaf, you also need to define a file latexmkrc in your root folder :

# This is file is necessary for corss referencing when using overleaf 

add_cus_dep( 'tex', 'aux', 0, 'makeexternaldocument' );

sub makeexternaldocument {
    # if the dependency isn't one of the files that this latexmk run will consider, process it
    # without this test, we would get an infinite loop!
    if (!($root_filename eq $_[0]))
    {   # PLEASE ENABLE ONLY ONE OF THE FOLLOWING
        # DEPENDING ON THE ENGINE YOU'RE USING
    
        # FOR PDFLATEX
        system( "latexmk -pdf \"$_[0]\"" );

        # FOR LATEX+DVIPDF
        # system( "latexmk \"$_[0]\"" );

        # FOR XELATEX
        # system( "latexmk -xelatex \"$_[0]\"" );
        
        # FOR LUALATEX
        # system( "latexmk -lualatex \"$_[0]\"" );
   }
}

Your MWE is not complete so I could not test if that really worked in your specific example. But I do not see why it should not. Have a look at this also : https://www.overleaf.com/learn/how-to/Cross_referencing_with_the_xr_package_in_Overleaf

Note that you need to compile file2 at least once before you compile file1 in my example above so that the file1.aux can be created.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .