I've been reading through a number of answers that use \newsavebox to save the contents of a box. As far as I can tell it's a workaround for fragility of some kind. Is that right? If not, what is the point of saving a box?
|
Box usage isn't (normally) related to fragility. Boxes (and glue) are the fundamental typesetting constructs that TeX uses. All of TeX's typesetting is done by positioning boxes. Saving a box (as opposed to saving a command) means that you are saving a fragment of typeset text rather than saving a list of tokens to be executed. As mentioned in comments there are many reasons for wanting to do that. It might be to measure the width of some typeset construct, it might be that executing the commands is very costly in terms of execution time and you want to re-set copies of the same result multiple times, or it may just be that you want to pass a typeset fragment to another command (such as |
|||
|
|
|
i've used it to save and reuse a small graphic to replace the
relevant quote from the texbook (p.329):
|
||||
|
|
|
I can't name all of the situations to use a
The idea is to save the largest image into a box, which you can then measure to help with the
|
|||
|
|
|
Mostly I use it to reuse parts of graphics inside the
See https://en.wikibooks.org/wiki/LaTeX/Picture#Multiple_Use_of_Predefined_Picture_Boxes for another example and explanations. |
|||||||
|


\phantoms), or 2) re-use the content multiple times (say, same header content on all pages). – morbusg Dec 16 '12 at 11:48