Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@trylks
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trylks/6bbbdaff10b5dd35d676 to your computer and use it in GitHub Desktop.
Save trylks/6bbbdaff10b5dd35d676 to your computer and use it in GitHub Desktop.
Automatic paper description
% Simply this:
% write \contents{whatever} to add that to the description and write \listofstructure{} to show the description. That's everything.
\newcommand{\listofstructure}{\InputIfFileExists{toc.toc}{}}
\newcommand{\contents}[1]{\immediate\write\delayedtext{In section\unexpanded\expandafter{~}\arabic{section} #1. }}
\AtBeginDocument{\newwrite\delayedtext
\immediate\openout\delayedtext=toc.toc.aux
}
\AtEndDocument{
\immediate\closeout\delayedtext
\newwrite\delayedtext % open the file to write to
\immediate\openout\delayedtext=toc.toc
\newread\prevtext
\openin\prevtext=toc.toc.aux
\begingroup\endlinechar=-1
\loop\unless\ifeof\prevtext
\read\prevtext to\fileline
\immediate\write\delayedtext{\unexpanded\expandafter{\fileline}}
\repeat
\endgroup
\immediate\closein\prevtext
\immediate\closeout\delayedtext
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment