提取包问题:不存在 \Sectionformat 语句被提取

提取包问题:不存在 \Sectionformat 语句被提取

我使用所示的解决方案这里(感谢 Mike Renfro!)从我的 LaTeX 文档中提取摘要。遗憾的是,我在标题的输出方面遇到了困难。基本上,问题是提取包提取了文档中不存在的命令。

\section{section} 

获取

\section[section]{\Sectionformat {section}{1}}

这会导致编译错误。

以下是代码的 MWE

\documentclass{article}
\usepackage{tocbasic}
\usepackage{afterpage}
\usepackage{pdflscape}
\usepackage{eso-pic} %exact placement of figures
\usepackage[below]{placeins} %prevents floats of getting over a FloatBarrier
\usepackage{pdftexcmds}
\usepackage[font+=footnotesize]{subcaption}
%%%%%%% This is for extracting synopses %%%%%%%
%% see stackexchange
\usepackage{verbatim}
\let\synopsis\comment \let\endsynopsis\endcomment
% Extract synopsis environments, \section commands, and \tableofcontents
% commands into a separate synopsis.tex file. In that file, a synopsis
% environment will be a simple semantic environment with no extra decoration.
\usepackage[active,generate=synopsis, extract-env={synopsis},  
extract-cmd={section,subsection,subsubsection}, %extract on section, subsection and sub subsection level
extract-cmdline={tableofcontents}
]{extract}
\begin{extract}
\newenvironment{synopsis}{}{}
\end{extract}

  \usepackage[hidelinks,pdfa,pdfencoding=auto,pdfusetitle,hypertexnames=false]{hyperref}
%,hypertexnames=false

%%%%%%

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{introduction} \begin{synopsis} Some text \end{synopsis} Main
text

\end{document}

这是输出

%% 
%% This is file, `synopsis.tex',
%% generated with the extract package.
%% 
%% Generated on :  2016/01/11,19:26
%% From source  :  mwesynopsis.tex
%% Using options:  active,generate=synopsis,extract-env={synopsis},extract-cmd={section,subsection,subsubsection},extract-cmdline={tableofcontents}
%% 
\documentclass{article}
\newenvironment{synopsis}{}{}

\begin{document}

\section[introduction]{\Sectionformat {introduction}{1}}

\begin{synopsis}
Some text
\end{synopsis}

\end{document}

我收到编译错误

\section[introduction]{\Sectionformat {introduction}{1}}

使用 XeTeX 进行编译

! Undefined control sequence.
<argument> \Sectionformat 
                          {introduction}{1}
l.14 ...duction]{\Sectionformat {introduction}{1}}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

任何有关如何摆脱这个错误的提示都受到热烈欢迎

答案1

\Sectionformat来自hyperref包。因此,如果您确保将其包含在extract*环境的概要文档中,那么一切应该都能正常工作。如果您需要概要中的其他包,请将它们extract*也添加到环境中。

您还应避免在概要后的行上添加文本,因为该文本将被忽略(您的原始文档正文中只有“文本”,而没有“正文”)。

\documentclass{article}
\usepackage{verbatim}
\let\synopsis\comment \let\endsynopsis\endcomment
\usepackage[active,
generate=synopsis,
extract-env={synopsis},  
extract-cmd={section,subsection,subsubsection},
extract-cmdline={tableofcontents}
]{extract}
\usepackage{tocbasic}
\usepackage{afterpage}
\usepackage{pdflscape}
\usepackage{eso-pic}
\usepackage[below]{placeins}
\usepackage{pdftexcmds}
\usepackage[font+=footnotesize]{subcaption}
\begin{extract*}
\usepackage[hidelinks,pdfa,pdfencoding=auto,pdfusetitle,hypertexnames=false]{hyperref}
\end{extract*}
\begin{extract}
\newenvironment{synopsis}{}{}
\end{extract}

\begin{document}
\section{introduction}
\begin{synopsis} Some text \end{synopsis}
Main text
\end{document}

相关内容