Array programming languages have the concept of boxing. J is such a language. Boxes can contain anything, nothing included. Most of all, because of array languages' design, boxing happens from the outside inwards, and is also visually presented that way, as can be seen in the environment provided by fancyvbr, wherein lays the result from jconsole from an input of <(<1),<<2.

For non-nested examples, e.g. list of empty and 1, \fbox{} suffices.

However, for a box of (a box with 1) and (a box with (a box with 2)), the two boxes' frames at level 1 do not align because they are constructed from the inside out, that is, they grow instead of shrink.

I sought for similar quandries in the TeX SE, I sought boxing and nesting packages in CTAN, but found nothing relevant. Using \hlines and nested \tabular would have worked were it not for no explicit \vspace{...}. I may missing something very simple, but I expect a massive block of TiKZ code, nothing simple.

Here is my practice sheet, that is the MWE:

  \newlength{\myht}   \settoheight{\myht}{0}
  \newlength{\mydp}   \settodepth{\mydp}{0}
  \newlength{\mylen}  \setlength{\mylen}{\dimexpr\baselineskip-\myht-\mydp-1.1pt\relax}
  \def\ebox{\fbox{\hbox to 0.25ex{\vbox to \mylen{}}}}



\fbox{ \begin{tabular}{|c|c|}\hline 1 & \fbox{ \hbox to 0.2ex {\vbox to 5ex{}}2 }\\ \hline\end{tabular} }
││ ││2│││
││ │└─┘││

1 & \fbox{2} \\

\fbox{\fbox{\ebox}\fbox{1 2}}\\
\begin{minipage}{2cm}\begin{tcbitemize}[size=fbox,sharp corners,colframe=black,colback=white,raster equal height,raster force size=false,raster equal skip=0pt,raster column skip=2mm]%
\tcbitem 1 2 3%
\tcbitem 1 2%

Which compiles to enter image description here

EDIT: I want to reproduce the Verbatim example. It doesn't matter whether boxes' contents are vertically centered, only that boxes at the same level have frames at the same baseline, that is, their depths and heights are the same.

  • 1
    Your question is rather hard to follow. Perhaps it would be easier if we could see the MWE output but the supplied code gives ! Missing \endcsname inserted. <to be read again> \protect l.4 \DefineShortVerb{\Ь} Jul 13 at 18:21
  • What exactly do you mean by "do not align?" All boxes, whether next to each other or nested, share the same baseline. Tabular and minipage have multiple baselines inside and have to choose one. See also \vbox, \vcenter and \vtop. Jul 13 at 18:23
  • Can you clarify what you want that is not this output from \fbox{\fbox{ 1 \fbox{ 2 }}} Jul 13 at 18:33
  • @DavidCarlisle Hey, Dave, long time no see, We talked on the chat long ago, I've lost account details. Anyway, the fboxed example is impossible in most-to-all array languages because at the same level you have both a number and a box (different data types)
    – r440
    Jul 13 at 18:46
  • 1
    you may find that not providing untested broken examples and not being rude to people offering to help makes it more likely you get answers. Jul 13 at 20:35

3 Answers 3


Maybe this??





\cbox{\cbox{\cbox{\cbox{1,2},3,4}, 5}}


enter image description here


This shows how to match the height, width or both of a savebox.


\newcommand{\matchbox}[2]% #1 = box register, #2 = contents







Not a great answer, but fiddling with the frame width and the separation lengths an invisible box could be salable:




EDIT: Increasing the fboxsep by the to-be-gone fboxrule helps alleviate the discrepancy, but there persists a visible distance between neighboring boxes, something miniscule, like 1 pixel.

  • 1
    Please embed and highlight somehow your solution in the code, which is complete in the senses of: "can be copied and compiled". Wrt the question including a screenshot may be helpful, too.
    – MS-SPO
    Jul 13 at 21:14

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.