This might have been asked before, but I am not sure what to search for.
I am often in the situation that I want to print identical portions of text (or images, tables, etc) on a single A4 page in order to hand them out to a group of people. So for instance I might want to print 2x4 identical tables on a single page.
In principle I could type one portion and copy/paste the others in my editor, putting all of them into a table or using minipages etc.
However I'd rather have the text only once in my tex-file, so that I can later edit it easily. So I would somehow tell LaTeX that I want to save this portion of code and reuse it later with another command.
I guess input/include could work, but I'd rather have all of it in a single file.
How can I achieve this?
\def
is for...\def\codeA{...}
. Then, whenever you type\codeA
, the defined code is substituted in its place. The particulars could vary a little based on the context of your usage (which you did not provide). If you want to save the rendered version, rather than the raw code to reproduce it, the\savestack
macro (stackengine
package) could be of use. It renders the code in a box whose name you provide.