我正在尝试在撰写会议记录时自动添加决策摘要。对于会议的每个段落,我使用表格来组织段落编号、名称和内容,并使用 etoolbox 和 csdef 来跟踪以下决策这答案。在表格中使用 \motion 命令时,我无法让它工作。有人知道为什么或如何解决这个问题吗?
梅威瑟:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{float}
\newcommand{\enter}{\vskip 3mm}
\newcommand{\decision}[1]{\textbf{The board decided}\\
\textit{to(1)} #1}
\newcommand{\approve}{approve the motion}
\newcommand{\wrapper}[3]{
\begin{table}[H]
{\renewcommand\arraystretch{1.25}
\begin{tabular}{p{0.5cm} p{4cm} p{10cm}}
#1 & \raggedright{#2} & \raggedright{#3}\\
\end{tabular}
}
\end{table}
}
\makeatletter
\newcommand*{\@showMotion}[1]{%
\showMotion{#1}%
}
\newcommand*{\showMotion}[1]{%
\csuse{name #1} motions to(1)\\\textit{"\csuse{motion #1}"}\enter
\decision{\csuse{decision #1}}\enter
}%
\newcommand*{\summary}{% Initialize
}
\newcommand{\addToMotions}[1]{%
\g@addto@macro\summary{{#1}}%
}
\newcommand{\motion}[3]{%
\ifcsdef{name #1}{%
\PackageError{\jobname}{Multiple uses of the key: '#1'}{}%
}{%
\csdef{name #2}{#1}%
\csdef{motion #2}{#2}%
\csdef{decision #2}{#3}%
\addToMotions{{\@showMotion{#2}}}%
}%
#1 motions to(1)\\\textit{"#2"}\enter \decision{#3}\enter
}
\makeatother
\begin{document}
\motion{Test Testersson}{begin testing}{\approve}
\wrapper{§1}{Test}{\motion{Foo bar}{Lorem Ipsum}{\approve}}
\wrapper{§2}{Summary}{\summary{}}
Summary:\\\\
\summary{}
\end{document}
其结果是:
答案1
我不能说我明白原作者想要什么;但是,很明显,\csdef
当调用发生在tabular
单元格中时,它将受制于表格单元格的范围。因此,执行这些调用\global
会将信息传递给正在关注的其他宏。
\addToMotions
不需要改变,因为它已经使用了\g@addto@macro
,这是一个全局分配。
\documentclass{article}
\usepackage{etoolbox}
\usepackage{float}
\newcommand{\enter}{\vskip 3mm}
\newcommand{\decision}[1]{\textbf{The board decided}\\
\textit{to(1)} #1}
\newcommand{\approve}{approve the motion}
\newcommand{\wrapper}[3]{
\begin{table}[H]
{\renewcommand\arraystretch{1.25}
\begin{tabular}{p{0.5cm} p{4cm} p{10cm}}
#1 & \raggedright{#2} & \raggedright{#3}
\end{tabular}
}
\end{table}
}
\makeatletter
\newcommand*{\@showMotion}[1]{%
\showMotion{#1}%
}
\newcommand*{\showMotion}[1]{%
\csuse{name #1} motions to(1)\\\textit{"\csuse{motion #1}"}\enter
\decision{\csuse{decision #1}}\enter
}%
\newcommand*{\summary}{% Initialize
}
\newcommand{\addToMotions}[1]{%
\g@addto@macro\summary{{#1}}%
}
\newcommand{\motion}[3]{%
\ifcsdef{name #1}{%
\PackageError{\jobname}{Multiple uses of the key: '#1'}{}%
}{%
\global\csdef{name #2}{#1}%
\global\csdef{motion #2}{#2}%
\global\csdef{decision #2}{#3}%
\addToMotions{{\@showMotion{#2}}}%
}%
#1 motions to(1)\\\textit{"#2"}\enter \decision{#3}\enter
}
\makeatother
\begin{document}
\motion{Test Testersson}{begin testing}{\approve}
\wrapper{§1}{Test}{\motion{Foo bar}{Lorem Ipsum}{\approve}}
\wrapper{§2}{Summary}{\summary{}}
Summary:\\
\summary{}
\end{document}