Last active
August 29, 2015 14:02
-
-
Save trylks/6bbbdaff10b5dd35d676 to your computer and use it in GitHub Desktop.
Automatic paper description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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