[TOC]
交叉引用1
使用背景:假设你有2个tex文件:file1.tex和file2.tex,你想要在file1中引用file2中的表格、图表、算法、公式、章节等,同时也可能需要在file2中引用file1中的内容。这时如果手动输入,则存在诸多不便:不方便更新、不方便维护。那有没有全自动的方法呢?答案是有的。
方法如下:
%file1中增加内容:
\usepackage{xr}
\externaldocument{file1}
%file2中增加内容:
\usepackage{xr}
\externaldocument{file2}
通过引用xr包,然后再声明一下要引用的外部文档,就可以像引用自己文档的内容引用外部文档的内容了。
交叉引用2
一般在正文中引用补充材料里的内容时,需要同时标注引用的内容来自补充材料,例如引用了补充材料里的Table 2, 则正文中一般为 Table S.2 of the supplementary file,如何自动化实现呢?
方法如下:
% For 'Supplementary Figure S1'
\newcommand*\sfref[1]{\ref{#1} of the supplementary file} % figure
% For 'Supplementary Table S1'
\newcommand*\stref[1]{\ref{#1} of the supplementary file} % table
% For 'Supplementary Materials S1'
\newcommand*\smref[1]{\ref{#1} of the supplementary file} % section
\newcommand*\saref[1]{\ref{#1} of the supplementary file} % algorithm
然后引用的时候用\stref{要引用的label}引用相应的表格就可以了。图、表、算法、章节等的引用格式可以自定义。
修改章节标题样式
一般论文的补充材料中的章节、图、表、算法等都是以S.开头,表示supplementary file的意思,那么如何自动化实现呢?
方法如下:
\renewcommand{\thetable}{S.\arabic{table}}
\renewcommand{\thefigure}{S.\arabic{figure}}
\renewcommand{\thealgorithm}{S.\arabic{algorithm}}
\renewcommand{\thesection}{S.\arabic{section}}
效果如下:
image.png
image.png