1

Is there any problems in the future if I use individual .tex files for individual figures? For example, instead of having the code below,

some text 

\begin{figure}[h!]
  \includegraphics[scale=1.7]{birds.jpg}
  \caption{The birds}
  \label{fig:birds}
\end{figure}

some more text

it would be something like this.

some text

\insert{figure_about_birds.tex}

some more text

figure_about_birds.tex would be the section of code below.

\begin{figure}[h!]
  \includegraphics[scale=1.7]{birds.jpg}
  \caption{The birds}
  \label{fig:birds}
\end{figure}

It might be a hassle to try to go back and fix the formatting of the figure, but I think the main .tex file will read a lot better if it is like this. I also don't want to do something naughty that will hurt me in the future.

  • Hi and welcome to the site! I don't know which tools you're using, but with the right editor you could keep all the lines in your one file and use cold folding to streamline the look. en.wikipedia.org/wiki/Code_folding – James Oct 3 at 13:18
  • Cool! I use overleaf, and it looks like that is an option. I guess one problem with it is that the figure name does not show when it is folded. It just says " \begin{figure}<-> \end{figure}". Regardless, it is a neat trick. Thanks! – ZachS Oct 3 at 14:00
3

You can use \input for this (there is no \insert command in latex by default). That should have no issues at all.

Unrelated though: you should not use [h!] LaTeX will usually warn about that and change the option.

1

keyfloat package provides an equally short syntax without making editing of additional files necessary:

\documentclass{article}

\usepackage{keyfloat}

\begin{document}

some text 

\keyfig[h!]{s=.5,c={The birds},l={fig:birds}}{birds}

some more text

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.