我使用该catchfilebetweentags
包从一个公共文件中获取特定内容.tex
。存储所有内容的文件的 MWE(称为master.tex
):
\documentclass[]{article}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage[top=1in, bottom=1in, left=1.5in, right=1.5in,footskip=0in]{geometry}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.14in}
\begin{document}
\pagenumbering{gobble}
\pagestyle{fancy}
\lhead{Past exam questions}
\rhead{Database}
%<*18mj-43-2-5>
\begin{enumerate}[label=\alph*$)$, rightmargin=0.05\linewidth, leftmargin=0.05\linewidth]
\item Explain why the concept of the margin is significant in the economic theory of consumer behaviour. [12]
\item Discuss whether the calculation of a marginal cost or an average cost is more significant in reaching conclusions about economic efficiency. [13]
\end{enumerate}
%</18mj-43-2-5>
\end{document}
请注意,此文档被标记为18mj-43-2-1
。-5
末尾的 是问题类型的标识符。这个问题是类型 5。
输出类型 1 问题的文档的 MWE(称为type1.tex
):
\documentclass[]{article}
\usepackage{fancyhdr}
\usepackage{catchfilebetweentags}
\usepackage{xstring}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage[top=1in, bottom=1in, left=1.5in, right=1.5in,footskip=0in]{geometry}
\def\i{May/June 2017, QP 43, Q2}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.14in}
\begin{document}
\pagenumbering{gobble}
\pagestyle{fancy}
\lhead{Past exam questions}
\rhead{Topic 1}
This line should execute only if the Execute Metadata is not empty.
\ExecuteMetaData[master.tex]{18mj-43-2-1}
This line should execute regardless.
\end{document}
我希望上面的文本行\ExecuteMetaData
是有条件的;仅当命令返回输出时才运行。在此处的示例中,不会有输出\ExecuteMetaData
(因为此文档仅显示类型 1 的问题)。
如何实现这一点?