2

I am using the array environment with \begin{array}{l@{::=}ll} to typeset a formal grammar:

Rendered version of the LaTeX code below showing the ::= delimiter in the supposedly empty line

How can I insert an empty line without my delimiter ::= appearing there?

Minimal working example:

% !TeX TS-program = xelatex
% !TeX encoding = UTF-8
% !TeX spellcheck = en_US
\documentclass[]{article}
\usepackage{amsmath}
\begin{document}

\[
    \begin{array}{l@{\quad::=\quad}l@{\quad}l}
        T   & \varepsilon \mid \mathrm{leaf} \mid \mathrm{bin}(T, T) & \text{trees}\\
        \\
        F   & \varepsilon \mid F, T                                  & \text{forests}
    \end{array}
\]

\end{document}
4

You can simply use an empty \multicolumn, as its column specifications override the specifications of the tabular/ array it is inserted in.:

\documentclass[]{article}
\usepackage{amsmath}

\begin{document}

\[
    \begin{array}{l@{\quad::=\quad}l@{\quad}l}
        T & \varepsilon \mid \mathrm{leaf} \mid \mathrm{bin}(T, T) & \text{trees}\\
       \multicolumn{1}{c}{} & &\textit{Fiddle dee dee }\\\\
        F & \varepsilon \mid F, T & \text{forests}
    \end{array}
\]

\end{document} 

enter image description here

|improve this answer|||||
  • 1
    @ComFreek Bernard has essentially done that as he used \multicolumn{1} so only removed the @ from the first column, try \multicolumn{1}{c}{aaa}&bbb&ccc\\ this will still give you the \quad from the second @ – David Carlisle Feb 27 at 17:12
  • @DavidCarlisle Ah, I see now that \multicolumn{1}{###}{...} can be used to "override" the column layout & delimiter of the current column by ### with column contents ###! I think that information is worth adding. So \multicolumn{1}{c}{}&&\text{dummy header} would produce the expected row for me. – ComFreek Feb 27 at 17:25
  • @ComFreek: I've added some words about what \multicolumn does and some nonsense text in the third column. – Bernard Feb 27 at 17:44
5

Some suggestions and observations:

  • Instead of inserting a not-so-empty line in the array via a \\ directive, just increase the amount of vertical skip after the first \\ directive by, say, 3ex.

  • Setting an explicit intercolumn whitespace amount of \quad is redundant in most document classes, i.e., in all those document classes which set the value of \tabcolsep to 6pt and the value of \quad to 12pt. Unless specified otherwise, intercolumn whitespace amounts to 2\tabcolsep.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "\text" macro
\begin{document}
\[
    \begin{array}{ l @{\quad::=\quad} l l }
        T   & \varepsilon\mid\mathrm{leaf}\mid\mathrm{bin}(T, T) & \text{trees}\\[3ex] 
        F   & \varepsilon\mid F, T                               & \text{forests}
    \end{array}
\]
\end{document}
|improve this answer|||||

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.