Make a Captions Page - latex

I want to know if there is an easy way to extract the captions of one latex file with the numbers of the figures they are from.
For example if I have 3 figures in defined in my latex file, I need to create a document with the captions of those figures, e.g.,
Fig. 1. Caption of Fig. 1
Fig. 2. Another caption
Fig. 3. Yet another caption
Is there any way of doing this using latex? or should I do it with other program?
I have several figures, so I don't want to go and extract the captions one by one, because I have to number them manually.
Solution.
I solve the problem with a work around. I use another file to include the list of figures and process them separately. The file that I included contains a modified list of figures as follows
{\renewcommand*\numberline[1]{Fig.\,#1:\space}
\makeatletter
\renewcommand*\l#figure[2]{\noindent#1\par}
\makeatother
\listoffigures}
Then, I include it in the original file with \include command. Then it creates the list of figures file as file.lof, I used that file to compile a minimal file to produce the list of figures separately.
\documentclass{article}
\usepackage{subfigure} % This avoids problems with subfigures captions
\usepackage{amsmath,amssymb} % I used math in my captions
\nofiles % This makes the aux and lof file not to be deleted
\begin{document}
\include{list} % Includes the same file as before
\end{document}
I was using a different class, other than article, therefore, I need to copy some redefinitions in the auxiliar file. Rename the file.lof to this new file, so latex find it and it will do the work. I put all this in a script and now it works automatically.
Hth.

The \listoffigures control sequence may help you.

Related

Is it possible to insert a gif in latex (Overleaf)? [duplicate]

This question already has an answer here:
How to add a gif/animation onto Beamer (post Adobe retiring Flash)
(1 answer)
Closed 26 days ago.
I'm writing a latex file on Overleaf and I would insert a gif image.
Is it possible? Because I didn't find any solutions.
I had the same problem and I solved it by converting the gif to a set of pngs and then using the animate package.
For the first task you can exploit one of the solution suggested here.
Once you have a series of image files named with a shared prefix (e.g. fig-) and an increasing index that track the order in which they have to appear, then the usage of `animate} is pretty simple:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx, animate}
\title{animate SO}
\date{January 2022}
\begin{document}
This is how to insert gif in main document:
% use the usual figure environment and substitute \includegraphics with \animategraphics
\begin{figure}
\centering
% \includegraphics{}
\animategraphics[width=\textwidth, loop, autoplay]{1}%frame rate
{figures/fig-}%path to figures
{1}%start index
{4}%end index
\caption{Local gif}
\label{fig:my_label}
\end{figure}
\end{document}
Notice that I needed to express the path to the location of the figures as./figures/<fig-prefix> in case the \animategraphics is called by an external tex file which is included in the main.
I created a sample overleaf project to showcase the usage.
Finally, I'd suggest have a look to StackExchange LaTeX for latex related question :)

Rmarkdown with LaTex-document in appendix?

I need to create an Rmarkdown document in which I have some text and 3 appendices showing 3 different LaTex files. I found many resources showing how to append Rcode in an appenidx, but have been unsuccessful for other kinds of appendices. As a structure, I use a thesisdown-template. The template has several chapters that are all compiled together in the end. There is also an appendix-template but I haven't figured out how to include a LaTex file in there. But given that I can have LaTex code in a Markdown file, it should be possible?
I do not need to use thesis-down, it could also be similar to the following:
Any ideas are welcome!
If I understand correctly, then you are only interested in PDF output. You can embed raw LaTeX commands in R Markdown, so the following should do what you need:
\appendix
## Appendix 1
\input{/path/to/my/LaTeXfile.tex}
## Appendix 2
\input{/path/to/my/other/LaTeXfile.tex}

How to include both Agda and Isabelle code in the same latex file?

I am creating presentation slides using beamer, and on the slides I want to include pieces of code from Agda and Isabelle standard libraries. All I can find online is generating latex from Agda (lagda) or from Isabelle (document preparation). I want to go the other way, as my slides will have code from different systems.
I can still use lstlisting or verbatim, but I would rather not copy-paste and reformat code.
I would prefer to have something like including line numbers from files, or maybe code between tags
Your best bet is to use the catchfilebetweentags package: given two files IsabelleCode.tex and AgdaCode.tex generated by the respective LaTeX backends of each language, you can capture the code between an opening tag %<*TAGNAME> and a closing tag %</TAGNAME> in either file by using the appropriate directive e.g.:
\ExecuteMetaData[IsabelleCode.tex]{TAGNAME}
\ExecuteMetaData[AgdaCode.tex]{TAGNAME}
With \lstinputlisting from the listings package, you can directly include code from the source file. Optionally you can specify the start and end line numbers
\documentclass{beamer}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\begin{document}
\begin{frame}[fragile]
\lstinputlisting[firstline=1,lastline=7,language=C]{duck.C}
\end{frame}
\begin{frame}[fragile]
\lstinputlisting[firstline=1,lastline=7]{test.agada}
\end{frame}
\begin{frame}[fragile]
\lstinputlisting[firstline=1,lastline=7]{test.isabelle}
\end{frame}
\end{document}
At least for Agda, you can render individual .lagda modules into LaTeX. If you can do the same with Isabelle's pretty-printer, you should be then able to write toplevel LaTeX by hand, and then import (parts of) the Agda and Isabelle-generated LaTeX where appropriate.

Conditional Import in LaTeX?

I'm going to be taking a ton of lecture notes, and then compiling them into LaTeX so that I can have excellent documents for future me to look over. I'm trying to organize things so that I can have a bunch of little documents containing the notes from a lecture, and then compile them at the end of the semester into one large document containing all of them. I have used import/include etc. successfully in the past, but I've had to remove the content at the head and foot of the sub-documents before compiling the main document. For example, I would have to remove:
\begin{document}
and
\end{document}
from every sub-document before compiling the main document. This is fine for a report with 5 or so sections, but a pain in the ass for something with 100+. Any recommendations for ignoring the contents of a LaTeX file programmatically when using the import command?
I see two approaches here. Either carefully structure your documents, or use some hacky TeX magic:
The smart way
Break your smaller documents into a header part, a footer part and a content part.
header.tex:
\documentclass{article}
...
\begin{document}
footer.tex:
\end{document}
foo-content.tex:
In this paper, we discuss an new approach to metasyntactic variables...
foo.tex (the small paper version):
\include{header}
\include{foo-content}
\include{footer}
In your .tex for the collected articles document:
\include{foo-content}
The hacky TeX way
Put this in some common include file, used by your individual files:
\ifx\ismaindoc\undefined
\newcommand{\inbpdocument}{\begin{document}}
\newcommand{\outbpdocument}{\end{document}}
\else
\newcommand{\inbpdocument}{}
\newcommand{\outbpdocument}{}
\fi
Use \inbpdocument and \outbpdocument in your individual files, in place of \begin{document} and \end{document}. In your main file, put in a \def \ismaindoc {} before including or importing anything.
Here's another possible approach: if you put magic strings (i.e., "% % BEGIN LECTURE % %" ... "% % END LECTURE % %") in the individual files, you could awk out the guts of the individual files, assemble them using make/sh, and then \include them.
There's another hack you could use, which wouldn't require modifying the individual files... just temporarily redefine the {document} environment (to something benign, i.e. a no-op), \include the individual files, and then restore the {document} environment definition.
If I recall correctly, the commands to do this are \let and \renewenvironment.
Hm. You might also have to temporarily redefine \documentclass and \usepackage, too. It's a hack, yes, but I think it should work.
I haven't used it, but it looks like the "subfiles" package does exactly what you want:
http://en.wikibooks.org/wiki/LaTeX/Modular_Documents#Subfiles_package

Latex, TikZ and separate compilation of chapters and figures

I have fairly large Latex document with a lot of TikZ figures inside. I have a habit of frequent recompilation and it takes forever to compile it using pdflatex. Figures in TikZ take most of the time.
My question is what is the best way to split the document into separate tex files (figures/chapters) to achieve separate compilation of figures and chapters, separate chapter pdfs, and a whole document pdf file ?
Have you tried compiling each picture on its own and then including them in your tex file as pdf rather than the tikz code? You can use the package standalone so that the picture will be the exact size you need. So :
\documentclass{standalone}
\usepackage{tikz,pgf} %and any other packages or tikzlibraries your picture needs
\begin{document}
\begin{tikzpicture}
%your tikz code here
\end{tikzpicture}
\end{document}
The good thing about this is that you can either include the compile this document directly to get a pdf figure to include in your document, or you can use the command \input to include it in your main document as a tikz code by adding
\usepackage{standalone}
in your main document (together with the tikz packages and libraries), and then
\begin{figure}
\input{tikzfile.tex}
\end{figure}
There is a possibly better way (imho) to cache tikz-pictures. Add the following lines in your
preamble:
\usetikzlibrary{external}
\tikzexternalize[prefix=i/]
After a pdflatex-run you'll see all pictures in the subdirectory ./i .
If you update the code of a tikz-picture simply throw away its corresponding pdf-file and it will be regenerated. For more info see the manual of PFG/TikZ section 32.4 Externalizing Graphics
and possibly 32.5 Using External Graphics Without pgf Installed.
How about putting each chapter in a separate file and then using \include to put them into some master file? Then you can use \includeonly to only compile the chapter you're currently working on. That should save some time at least.
I expect some sort of makefile based solution would be even better than this, but I don't know anything about makefiles...
The way I generally do this is to apply Latex to just part of the file: Emacs and several other Latex editors allow you to compiler regions: with Auctex, you can run TeX-pin-region to specify the current chapter, and then TeX-command-region to run Latex on the selected region.
The traditional way to do this is cut parts of the big file into smaller parts that are \included, and then either comment out parts you don't want to work on, or put some macrology at the beginning and end of each file that allows them to be compiled separately.

Resources