6
$\begingroup$

I have the code:

l = {{1, 2, 3}, {1, 2, 3}};
l = Append[l, PadLeft[{1}, 3, Null]];
TeXForm[TableForm[l]]

Returns

\begin{array}{ccc}
 1 & 2 & 3 \\
 1 & 2 & 3 \\
 \text{Null} & \text{Null} & 1 \\
\end{array}

But I am looking to get the last row as

  & & 1 \\

What is the way to do that, I was hoping that Null would be removed. I tried empty string, but it still leads having \text{} in the output.

$\endgroup$
2
  • 5
    $\begingroup$ Export to a string using ExportString[TexForm[...], "Text"] and the use StringReplace[%, "\\text{Null} " -> ""]? $\endgroup$
    – MarcoB
    Commented Apr 17, 2023 at 14:30
  • $\begingroup$ Not quite perfect, but what about "" as placeholder? (This results in \text{}, which prints as nothing) $\endgroup$
    – Lukas Lang
    Commented Apr 17, 2023 at 16:38

2 Answers 2

6
$\begingroup$

You can create an object that TeXForm will treat as an empty string:

MakeBoxes[foo, TraditionalForm] ^:= RowBox[{}]

Then:

TeXForm[TableForm[{{1, 2, 3}, {1, 2, 3}, {foo, foo, 1}}]]

produces:

\begin{array}{ccc}
 1 & 2 & 3 \\
 1 & 2 & 3 \\
  &  & 1 \\
\end{array}

which renders as:

\begin{array}{ccc} 1 & 2 & 3 \\ 1 & 2 & 3 \\ & & 1 \\ \end{array}

$\endgroup$
-2
$\begingroup$

Since the invention of 0 by the Indians to save the place between to ciphers in decimal strings against neclection or overwriting, there has to be something in TeX to hold the place

l = {{1, 2, 3}, {1, 2, 3}};
l = Append[l, PadLeft[{1}, 3, Esc sq Esc]];

TeXForm[TableForm[l]]

\begin{array}{ccc}
 1 & 2 & 3 \\
 1 & 2 & 3 \\
 \square  & \square  & 1 \\
\end{array}

l

array with placeholder

I justwas remembering there are other invisible characters treated as symbols, that don'produce \text in TeX. But now the browser interface here is clueless with naked unicode, so that I have it deliver as string.

In[82]:= 
TeXForm[ {{1,2,4},{a,b,c},{\[LetterSpace],\[LetterSpace],1}}//TableForm]


  "\begin{array}{ccc}  1 & 2 & 4 \\  a & b & c \\  \unicode{f754} &
  \unicode{f754} & 1 \\ \end{array}"

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.