The Question
Can I use a TeX primitive in a "before" and "after" macro? (and how?)
There are two questions that I found useful and related to my question, which sent me in the right direction: how to even ask this question!
- What are the different kinds of boxes in (La)TeX?
- Why does LaTeX make a distinction between commands and environments?
- How to make a list of unbreakable items?
- How to prevent pagebreak in description environment
Example Situation
I am using a custom list setup with the enumitem
package and I would like to use a primitive in the variables below:
\newlist{legal}{enumerate}{10}
\setlist[legal]{label*=\texttt{\arabic*.},resume,before={<HERE>}, after={<HERE>}}
I would like to put \vbox{
in the before={}
and }
in the after={}
, but obviously I cannot type before={\vbox{}, after={}}
Why would I want to do this? For example, I could want to put a box around each mother and daughter list item, such that they remain on the same page. Or maybe I would like to put other primitives around my list environment just for kicks. Is there any way to do this?
\vbox
.before=\begin{minipage}{\textwidth}, after=\end{minipage}
?minipage
is not a TeX primitive, it is an environment.vbox\bgroup
not\vbox{
and similarly\egroup
not}
then you can put it in your macro arguments without messing up brace matching. But to put\fbox
around a list you should not do that you should use thelrbox
environment which was explicitly added to latex for that example.