![仅当执行元数据不为空时才写入文本](https://linux22.com/image/383057/%E4%BB%85%E5%BD%93%E6%89%A7%E8%A1%8C%E5%85%83%E6%95%B0%E6%8D%AE%E4%B8%8D%E4%B8%BA%E7%A9%BA%E6%97%B6%E6%89%8D%E5%86%99%E5%85%A5%E6%96%87%E6%9C%AC.png)
我使用该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 的问题)。
如何实现这一点?