我有很多要引用的图表,我更喜欢在图表列表中给出简短的引用,即不提供来源,不幸的是,当我必须修复拼写错误等时,我需要更改简短标题以及完整标题。有没有一种好的方法可以只命名一次图表?(也许在文档中使用包含简短标题的变量,或者可能有更优雅的方法?)
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\usepackage[demo]{graphicx}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{A01,
author = {Albert Einstein},
title = {the true about tree},
journaltitle = {Annalen der Physik},
year = {1905},
volume = {322},
number = {10},
pages = {891--921}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\newtoks\shortcap
\shortcap={foo bar baz}
\begin{document}
\listoffigures
\begin{figure}
\centering
\includegraphics[width=3.0in]{example-image-a}
\shortcap={Some Text}
\caption[\the\shortcap]{\the\shortcap, Source:~\cite{A01}}
\end{figure}
\end{document}
答案1
我会采取相反的方式;定义不同的命令允许在棘手的情况下使用原始命令。
\begin{filecontents}{\jobname.bib}
@article{A01,
author = {Albert Einstein},
title = {the true about tree},
journaltitle = {Annalen der Physik},
year = {1905},
volume = {322},
number = {10},
pages = {891--921}
}
\end{filecontents}
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{xparse}
\addbibresource{\jobname.bib}
\NewDocumentCommand{\Caption}{om}{%
\IfNoValueTF{#1}
{\caption{#2}}
{\caption[#2]{#2. Source:~\cite{#1}}}%
}
\begin{document}
\listoffigures
\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-a}
\Caption[A01]{Some text}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-b}
\Caption{Some text}
\end{figure}
\end{document}
一种不同的方法,您可以添加完整的最终文本。
\begin{filecontents}{\jobname.bib}
@article{A01,
author = {Albert Einstein},
title = {the true about tree},
journaltitle = {Annalen der Physik},
year = {1905},
volume = {322},
number = {10},
pages = {891--921}
}
\end{filecontents}
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{xparse}
\addbibresource{\jobname.bib}
\NewDocumentCommand{\sourcecaption}{omm}{%
\IfNoValueTF{#1}
{\caption[#2]{#2#3}}
{\caption[#1]{#2#3}}%
}
\begin{document}
\listoffigures
\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-a}
\sourcecaption{Some text}{. Source:~\cite{A01}}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[width=3.0in]{example-image-b}
\sourcecaption[Some short text]{Some very long text}{, based on~\cite{A01}}
\end{figure}
\end{document}
答案2
您还可以使用在 lof 中消失的特定 cite 命令:
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\addbibresource{biblatex-examples.bib}
\newbool{showcites}
\DeclareCiteCommand\hiddencite{}{}{}{}
\DeclareRobustCommand\nottoccite[1][Source:~]{\ifbool{showcites}{#1\cite}{\hiddencite}}
\begin{document}
\boolfalse{showcites}
\listoffigures
\booltrue{showcites}
\begin{figure}
\centering
blub
\caption{blalbl
\nottoccite{shore}%
\nottoccite[, ][50]{aksin}%
\nottoccite[, and based on~][Vol][3]{herrmann}}
\end{figure}
\end{document}
但我不喜欢摆弄逗号和文本,因此从长远来看,我可能会简单地使用通用命令让文本在 lof 中消失:
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{caption}
\addbibresource{biblatex-examples.bib}
\newbool{show}
\DeclareRobustCommand\notintoc[1]{\ifbool{show}{#1}{}}
\begin{document}
\boolfalse{show}
\listoffigures
\booltrue{show}
\begin{figure}
\centering
blub
\caption{blalbl
\notintoc{Source:~\cite{shore}, \cite[50]{aksin}, and based on \cite[Vol][3]{herrmann}}}
\end{figure}
\end{document}