4

I am currently working with the gb4e package for linguistics in LaTeX, and I am wondering if there is an easy way to align parts across examples. For instance, in the following example, I want to left align "bar" with "something else."

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{gb4e}

\begin{document}

\begin{exe}
    \ex \begin{xlist}
        \ex foo: bar
        \ex something: something else
    \end{xlist}
\end{exe}

\end{document}
Alan Munn
  • 218,180
3thanguy7
  • 55
  • 2

1 Answers1

3

There is a handy package called listliketab which allows you to create tabular material that looks like a list. This can be used to do what you want quite easily. The listliketab package allows you to store the formatting properties of a list and then creates a tabular column type L for the label of the list. This column type gets used as the first column within a regular tabular. For an enumerated list like the xlist environment of gb4e you also need to set up a counter for the label. I've done this by creating a tabexe environment and a \tbex macro to increment and output the counter. Here's a full example:

\documentclass{article}
\usepackage{listliketab}
\usepackage{etoolbox}
\usepackage{gb4e}
\newcounter{tabex}
\renewcommand{\thetabex}{\alph{tabex}}
\storestyleof{xlista} % this stores the formatting of the sublist
\newcommand{\tbex}{\refstepcounter{tabex}\thetabex.}
\makeatletter
\newenvironment{tabexe}{\setlength{\llt@bot@sep}{0pt}\setcounter{tabex}{0}%
\begin{listliketab}}{\end{listliketab}}
\makeatother
\begin{document}
\begin{exe}
\ex
\begin{tabexe}
\begin{tabular}[t]{Lll} % make sure you add [t] to align with the main example number
\tbex & something & foo\\
\tbex & foo & something
\end{tabular}
\end{tabexe}
\end{exe}
\end{document}

output of code

Alan Munn
  • 218,180