General ⇒ toc of equations
-
- Posts: 2
- Joined: Wed Apr 16, 2008 9:59 am
toc of equations
I would like to create a toc with the equations I am using in the text in order to copy all of them into few pages and see if I am consistent with the notation throug all the document.
For example, if my document is like this
...text...
\begin{equation}
E=m \cdot c^2
\end{equation}
...text...
...text...
...text...
...text...
...pages...
...pages...
\begin{equation}
F=m \cdot a^2
\end{equation}
...text...
Then in my dvi, I would like to have an extra page at the beginning of my document just with
\begin{equation}
E=m \cdot c^2
\end{equation}
\begin{equation}
F=m \cdot a^2
\end{equation}
in order to compare them.
Thanks in advance.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
toc of equations
Here are a few pointers that might give you some ideas:
- Write a simple parser (in whatever programming language you know) that will extract all display math into a separate file and then compile that file with latex.
- Look at preview-latex package. It should allow you to output only your math as one equation per page. It should be then straightforward to auto-generate latex file that will further condense this output, e.g.
Code: Select all
\includegraphics[page=1]{previewfile.pdf} \includegraphics[page=2]{previewfile.pdf} ...
Tomek
Re: toc of equations
B.A.
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
toc of equations
welcome to the LaTeX Community board!
Concerning tocloft and list of equations we had a discussion here. gmedina gave an example there. Its a list without the math content though.
Stefan
toc of equations
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
% --------------------------------------------
% --------------------------------------------
% Load fancyvrb
\usepackage{fancyvrb}
% Name of a scratch file
\newcommand{\TempFile}{extractedcode.tmp}
% Name of the tex file with the extracted code
\newcommand{\LaTeXFile}{extractedcodee.tex}
% Command \AppendTempFile.
% Appends the contents of the temp file to those
% of the tex file. Choose the right definition
% depending on your system
% For Unix/Linux/Mac OS X
%\newcommand{\AppendTempFile}{%
% \immediate\write18{cat \TempFile >> \LaTeXFile}}
% For Windows
\newcommand{\AppendTempFile}{%
\immediate\write18{type \TempFile >> \LaTeXFile}}
% New environment ExtractCode.
% It extracts all the code that lies inside.
% The definition is a bit tricky. It is not
% done through \newenvironment
\newcommand{\ExtractCode}%
{\VerbatimEnvironment
\begin{VerbatimOut}{\TempFile}}
\def\endExtractCode{%
\end{VerbatimOut}
\input{\TempFile}
\AppendTempFile}
% --------------------------------------------
% --------------------------------------------
\begin{document}
% --------------------------------------
% Put the following lines whenever you want
% to start extracting code. Write inside
% VerbatimOut a suitable preamble for the tex
% file which will contain that code
\begin{VerbatimOut}{\LaTeXFile}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\end{VerbatimOut}
% --------------------------------------
% --------------------------------------
\begin{ExtractCode}
\title{A test}
\author{by Myself}
\date{\today}
\maketitle
\section{First section}
\end{ExtractCode}
% --------------------------------------
\lipsum[1-2]
% --------------------------------------
\begin{ExtractCode}
Here we have some equations
\begin{align}
x + y + u^2 - v &= -1, \\
2x^2 - 3y + 4z + u^3 &= 9, \\
2y^3 - z^2 + u - v &= -4.
\end{align}
\end{ExtractCode}
% --------------------------------------
\lipsum[3]
% --------------------------------------
\begin{ExtractCode}
\section{Second section}
\end{ExtractCode}
% --------------------------------------
\lipsum[4]
% --------------------------------------
\begin{ExtractCode}
Let $f(x,y)=2x-y+xy$. Then we have
\begin{equation}
\nabla f(x,y)=\mathbf{0}\Longrightarrow
\left.
\begin{alignedat}{2}
f_x(x,y)&={} & 2 &+y=0 \\
f_y(x,y)&={} & -1 &+x=0
\end{alignedat}
\right\}\Longrightarrow (x,y)=(1,-2)
\end{equation}
\end{ExtractCode}
% --------------------------------------
\lipsum[5]
% --------------------------------------
% Put the following lines whenever you want
% to stop extracting code.
\begin{VerbatimOut}{\TempFile}
\end{document}
\end{VerbatimOut}
\AppendTempFile
% --------------------------------------
Here we have the last equation, not included in the separate document:
\begin{equation}
E=m c^2
\end{equation}
\end{document}
Every piece of extracted code is temporarily saved in a file whose name is given by the \TempFile macro and then appended to \LaTeXFile. To this end, I use a command from the operating system: type in Windows or cat in Unix-like systems. To be able to call this commands, it is necessary to enable the shell-escape feature in your TeX distribution.
In the above code, I propose to add to \LaTeXFile two pieces of code, at the beginning and at the end, so this file can be compiled separately. After running the above code, I get the file extractedcode.tex which has the following lines:
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\title{A test}
\author{by Myself}
\date{\today}
\maketitle
\section{First section}
Here we have some equations
\begin{align}
x + y + u^2 - v &= -1, \\
2x^2 - 3y + 4z + u^3 &= 9, \\
2y^3 - z^2 + u - v &= -4.
\end{align}
\section{Second section}
Let $f(x,y)=2x-y+xy$. Then we have
\begin{equation}
\nabla f(x,y)=\mathbf{0}\Longrightarrow
\left.
\begin{alignedat}{2}
f_x(x,y)&={} & 2 &+y=0 \\
f_y(x,y)&={} & -1 &+x=0
\end{alignedat}
\right\}\Longrightarrow (x,y)=(1,-2)
\end{equation}
\end{document}
I hope it may help. Of course, you can extract not only equations but any piece of code.
- Attachments
-
- testextract.pdf
- (45.68 KiB) Downloaded 264 times
-
- extractedcode.pdf
- (37.15 KiB) Downloaded 268 times
-
- Posts: 2
- Joined: Wed Apr 16, 2008 9:59 am
Re: toc of equations
thank you very much for your idea. After one problem with my Latex environment I made it
successfully work. In this post I would like to explain the solution to the problem I found in
order to help other people.
The problem is related on how to enable the shell-escape option in the Latex environment.
The correct way of doing it is to type
Latex --shell-escape -interaction=nonstopmode '%source'
My problem was that I first tried to type the --enable-escape after -interaction flag and it did
not work!!!
Thank you very much for everything,
Monica.