1

In this answer, \null is said to be equivalent to \hbox{} and is therefore never needed. The same advice is more or less given here as it's not a user-level macro, which I take to be the same as "don't use it after \begin{document}".

I'm compiling a special calendar (using longtable), where some cells need to be empty. There's simply no entry for them. The original code which I'm borrowing uses \null for the blanks, but I'm wondering if that should be replaced by \hbox{} or if it would instead have any deleterious effects.

Here's an MWE stripped down to the bare bones. I don't know slash don't understand what's going on under the hood so to speak, but at least a Ctrl + F search-and-replace would be a trivial fix. Thanks for your insights.

\documentclass[11pt]{article}

\usepackage{longtable} \usepackage{multirow,makecell}

\begin{document}

\setlength\LTleft{0pt} \setlength\LTright{0pt} \setlength{\tabcolsep}{5pt} \renewcommand{\arraystretch}{1.4} \fontsize{8}{9}\selectfont

\begin{longtable}{>{\centering}p{0.025\textwidth}|>{\raggedright}p{0.040\textwidth}|>{\raggedleft}p{0.025\textwidth}|>{\raggedright\arraybackslash}p{0.85\textwidth}} text & text & text & text \ %% this looks ugly, it's fine for sample purposes. \null & \null & \null & text \ %% this generates empty space as needed. \hbox{} & \hbox{} & \hbox{} & text %% it appears the same as the above line.

\end{longtable}

\normalsize

\end{document}

1 Answers1

2

Since \null is the same as \hbox{}, there can be no difference.

But there's no difference also if you type in nothing at all, which is actually the preferred way.

\documentclass[11pt]{article}

\usepackage{longtable,array}

\begin{document}

\begingroup \setlength\LTleft{0pt} \setlength\LTright{0pt plus 1fil} \setlength{\tabcolsep}{5pt} \renewcommand{\arraystretch}{1.4} \fontsize{8}{9}\selectfont

\begin{longtable}{ >{\centering}p{0.025\textwidth}| >{\raggedright}p{0.040\textwidth}| >{\raggedleft}p{0.025\textwidth}| >{\raggedright\arraybackslash}p{0.7\textwidth} } T & T & T & T \ %% this looks ugly, it's fine for sample purposes. \null & \null & \null & T \ %% this generates empty space as needed. \hbox{} & \hbox{} & \hbox{} & T \ %% it appears the same as the above line. T & T & T & T \ %% this looks ugly, it's fine for sample purposes. & & & T \ %% this generates empty space as needed. & & & T \%% it appears the same as the above line. & & & \ %% this generates empty space as needed. & & & T \%% it appears the same as the above line. \end{longtable} \endgroup

\end{document}

enter image description here

egreg
  • 1,121,712
  • OK. So if \null is to be avoided, is \hbox{} in the same category? Or does it have legitimate (necessary even) usages? In any case, I'll go ahead and remove the extra "fluff." – DomMocquereau Jan 22 '23 at 21:14
  • @DomMocquereau \null is the same as \hbox{} – egreg Jan 22 '23 at 21:49
  • Right… I got that part. But my question is about the other way around. The previous answers say "don't use \null" and are silent about \hbox{} other than the answer to my own question where neither are needed (and since I've encountered it, I'd like to know if it should be avoided too…) – DomMocquereau Jan 22 '23 at 21:59