In my dissertation defense presentation (Beamer/TikZ), I have a particular slide with a model, built as tikzpicture, wrapped in a scalebox block for zoom control. It works fine.

However, I would like to reuse this diagram's code in another slide further in the presentation to display a smaller version of the same model (along with a text block) for reference, in order to avoid the need to navigate multiple slides backward and forward again. This is quite important, because: 1) I plan to use a presenter device (remote), which makes such transitions not feasible; 2) I don't want to abruptly switch the context and disrupt the flow of my presentation.

Ideally, I would like to define the model as LaTeX variable and refer to it in both places with different zoom levels, using scalebox. Is such reuse possible and, if yes, how could I do that?

  • 1
    Put the whole \begin{tikzpicture} ... \end{tikzpicture} in mytikzfigure.tex and then use \input{mytikzfigure}. Is that what you're looking for? – yo' Mar 28 '15 at 19:12
  • @yo': Thank you, but I prefer to have a single .tex file, if possible. – Aleksandr Blekh Mar 28 '15 at 19:13
  • 1
    \def\model{\begin{tikz....\end{tikzpicture}}and than just \model – touhami Mar 28 '15 at 19:21

I would prefer putting the code in another file mytikzfigure.tex -- including \begin{tikzpicture} and \end{tikzpicture} -- and using \input{mytikzfigure}.

If you want it in one file, then:

    \node {Hello};

and then \scalebox{0.5}{\myTikZfigure}.

  • Nice answer (+1). Thank you so much! Is there any particular reason for preferring placing code block in a separate file (considering that this is not a frequent matter throughout my presentation; I realize that, generally, it's a best practice for modularity)? Also, what is the difference between \newcommand you suggested and \def, suggested by touhami? – Aleksandr Blekh Mar 28 '15 at 19:28
  • 1
    @AleksandrBlekh Yes. Cleanliness. Currently, my slides have ~20 lines of code each, so it's easy to navigate the source. However, a TikZ figure can easily have hundreds of lines of code, whence I prefer it to be separate. I do that also for papers, needed to say. – yo' Mar 28 '15 at 19:33
  • 1
    @AleksandrBlekh see tex.stackexchange.com/questions/655/… i can say that \newcommand is better. – touhami Mar 28 '15 at 19:36
  • @AleksandrBlekh You can remove your comments that are not adding anything. It's actually encouraged to do so. – yo' Mar 28 '15 at 20:29

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.