3

I use the package gb4e to number my (linguistic) examples in tabular format. In some of these tables, I add an extra letter counter to (some of) the rows.

When there is a letter counter in the first row, there needs to be space between gb4e's number and the letter counter, as in the first example below (but perhaps not as much space as the example has). But when I don't have a letter counter in the first row, as when I use table headers, the huge gap between the example number and the letter takes up unnecessary space. In such cases, I would like to push the entire table leftwards so that the letter counters a and b end up right under the example number (or at least a lot closer to the margin than is the case now).

Suggestions?

\documentclass{article}
\newcounter{mycounter}
    \newcommand{\myletter}{
    \refstepcounter{mycounter}
    \themycounter)}
    \renewcommand\themycounter{\alph{mycounter}}
\usepackage{gb4e}
\begin{document}

\begin{exe}
\ex
    \begin{tabular}[t]{*3{l}}
    \myletter & Word & Word\\
    & Word & Word\\
    \myletter & Word & Word\\
    & Word & Word\\
    \end{tabular}\setcounter{mycounter}{0}
\end{exe}

\begin{exe}
\ex
    \begin{tabular}[t]{*3{l}}
    & \textsc{Header} & \textsc{Header}\\
    \myletter & Word & Word\\
    & Word & Word\\
    \myletter & Word & Word\\
    & Word & Word\\
    \end{tabular}\setcounter{mycounter}{0}
\end{exe}
\end{document}

enter image description here

3
  • 1
    Use something like \begin{tabular}[t]{@{\hspace{-1.5em}}*3{l}} which moves the tabular left by 1.5em.
    – Werner
    Nov 14 '13 at 20:57
  • @Werner Is there a macro here that contains/sets the space from the margin to the first column? If so, could I use that to push the table to the margin instead of using magic numbers like -1.5em?
    – Sverre
    Nov 15 '13 at 11:34
  • No, this is comprised of a number of lengths, since exe sets a list. I guess one can play around with lengths like \leftmargin, \itemindent, \itemsep, \labelsep, \labelindent, \labelwidth and maybe a couple more...
    – Werner
    Nov 15 '13 at 16:56
2

You have two spurious spaces in the definition of \myletter that shift it to the right; you can also remove the padding LaTeX by default adds to the left of a tabular.

\documentclass{article}
\newcounter{mycounter}

\newcommand{\myletter}{% <-- Add this
  \refstepcounter{mycounter}% <-- Add this
  \themycounter)}
\renewcommand\themycounter{\alph{mycounter}}
\usepackage{gb4e}
\begin{document}

\begin{exe}
\ex
    \begin{tabular}[t]{@{}*3{l}}% <-- Add @{}
    \myletter & Word & Word\\
    & Word & Word\\
    \myletter & Word & Word\\
    & Word & Word\\
    \end{tabular}\setcounter{mycounter}{0}
\end{exe}

\begin{exe}
\ex
    \begin{tabular}[t]{@{}*3{l}}
    & \textsc{Header} & \textsc{Header}\\
    \myletter & Word & Word\\
    & Word & Word\\
    \myletter & Word & Word\\
    & Word & Word\\
    \end{tabular}\setcounter{mycounter}{0}
\end{exe}
\end{document}

enter image description here

3
  • In my real document preamble, I actually have those % symbols where you placed them, for the purpose of explaining to myself what those commands are doing. Didn't realize it mattered in this case, but it explains why the white space in my example here was so monstrous. Following on Werner's comment above, I assume there's a macro (or macros) created by LaTeX that sets the space from the margin to the first column here. If so, I could add \begin{tabular}[t]{@{\hspace{-\magicmacro}}*3{l}} or something to that effect?
    – Sverre
    Nov 15 '13 at 11:33
  • @Sverre I'd simply use \hspace{-.5em} (or so) in front of \begin{tabular}.
    – egreg
    Nov 15 '13 at 11:42
  • I guess I'm trying to avoid using magic numbers (that said, I have noticed that magic numbers are apparently not frowned upon in the latex community).
    – Sverre
    Nov 15 '13 at 11:49

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.