- \usepackage[T1]{fontenc}
- \usepackage[dvips]{geometry}
- \usepackage{isolatin1,url,verbatim}
- \usepackage[english]{babel}
- \geometry{paper=a4paper,top=2cm,bottom=1.5cm,hdivide={1.5cm,*,2cm}}
- \jot0.3cm
- \frenchspacing
- {\endgraf\verbatim}%\noindent
- {\endverbatim}
- \date{January 12, 2000}
- \begin{document}
- \section{Description}
- This is a small Perl program I originally made when I was writing a program documentation for a large program consisting of several files; I wanted to extract the code out of the \LaTeX\ verbatim environments containing the whole code portionwise and have it put into a file which could then be compiled directly. This is how it works:\bigskip\par\noindent
- Options:
- \begin{description}
- \end{description}
- You can download it together with a short documentation as a tar.gz file from \url{http://www.geophysik.uni-frankfurt.de/~ruedas/download/xtrcode.tar.gz}.
- In the following I assume that \textit{texfile} is a program documentation.
- \begin{description}
- \item[\textit{codefile}:] \texttt{xtrcode} \textit{texfile} \textit{codefile} searches for a marker pattern followed by a blank and \textit{codefile} and copies the content of the following environment into the target file \textit{codefile}. This can be used to extract only the contents corresponding to a certain part of the program instead of the whole lot.---If no \textit{codefile} is given, the default output file is ``xtrcode.out''.
- \item[Option -a:] \texttt{xtrcode -a} \textit{texfile} extracts all contents of an environment from \textit{texfile} and writes it into the output file which is expected to be specified by the use of the marker pattern. This is useful if you have program code which is intended to come into separate files; when documenting it you will use a kind of extra pattern line, e.g. \verb/%%@ code1.f/ preceding each verbatim environment containing parts of \texttt{code1.f}, and similarly with the other files. With the \texttt{-a} option, \texttt{xtrcode} will interpret \texttt{code1.f} as the name of the file which shall contain the content of the following environment, and will copy the contents of all environments of the selected type into the respective target files.---The use of a marker pattern is necessary here, and no \textit{codefile} should be specified.
- \end{description}
- If there are nested environments of the same type, the outermost is assumed to be the one to extract.
- \section{Example}
- \begin{vverbatim}
- In the following I describe my sophisticated program which consists of a
- main program and a subroutine.\par
- In the main part, the subroutine is called:
- %%@ main.f
- \begin{verbatim}
- program main
- open(10,file="dat1",status="new")
- write (*,*) 'Enter number to be squared:'
- read (*,*) zin
- call sub1(zin,zout)
- \end{verbatim}
- Then the result is written to a file.
- %%@ main.f
- \begin{verbatim}
- write (10,*) zout
- close(10)
- end
- \end{verbatim}
- The subroutine calculates the result by
- \begin{equation}
- y=x^2.
- \end{equation}
- \verb/x*x/ was used instead of \verb/x**2/ to increase efficiency.
- %%@ sub1.f
- \begin{verbatim}
- subroutine sub1(x,y)
- y=x*x
- return
- end
- \end{verbatim}
- A further subroutine for calculation of cubes is under development.
- \end{vverbatim}
- With \texttt{xtrcode -a progdoc.tex}, all the code in the verbatim environments will be extracted, copying everything marked with \verb/%%@ main.f/ into a file \texttt{main.f} and everything marked with \verb/%%@ sub1.f/ into a file \texttt{sub1.f}. With \texttt{xtrcode progdoc.tex sub1.f} you can extract everything marked with \verb/%%@ sub1.f/; with \texttt{xtrcode -eequation -p progdoc.tex} you can extract all lines of all equation environments.
- \end{document}
Raw Paste