1

I use the solution shown here (thanks to Mike Renfro!) to extract a synopsis from my LaTeX documents. Sadly I am struggling with the output of the headings. Basically the problem is that the extract packages extracts commands that are not present in the document.

\section{section} 

gets

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

which gives an compile error.

Here is a MWE of the code

\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}

and this is the output

%% 
%% 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}

I get an compilation error for

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

compiling with 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.

Any hints how to get rid of this error are warmly welcome

louis cypher
  • 1,333

1 Answers1

2

\Sectionformat is from the hyperref package. So if you make sure you include it in the synopsis document with the extract* environment, things should work correctly. If you need other packages in the synopsis, add them to the extract* environment as well.

You should also avoid adding text on a line after a synopsis, as that text will be ignored (your original document only had "text", not "main text" in the body).

\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}
Mike Renfro
  • 20,550
  • I could not find the \Sectionformat inside the hyperref package documentation http://linorg.usp.br/CTAN/macros/latex/contrib/hyperref/doc/manual.pdf but I found it here http://www.bakoma-tex.com/doc/latex/hyperref/nameref.pdf – user Apr 21 '19 at 02:18