2

The normal behavior of a gb4e example environment is seen in (1) in the MWE below. But when I want two examples side by side, using minipage, the example is indented, and there is no space before or after the example environment.

How can I properly combine gb4e and minipage so that I get two examples side by side, but otherwise no differences from how it would look with a single example?

\documentclass{article}
\usepackage{lipsum, gb4e}
\begin{document}
\lipsum[4]
\begin{exe}
\ex An exe environment
\end{exe}
\lipsum[4]
\begin{minipage}[t]{0.5\linewidth}
\begin{exe}
\ex An exe environment
\end{exe}
\end{minipage}
\begin{minipage}[t]{0.5\linewidth}
\begin{exe}
\ex An exe environment
\end{exe}
\end{minipage}
\lipsum[4]
\end{document}

enter image description here

3

To preserve the spacing introduced by gb4e above and below, put minipage inside gb4e, not the other way around:

\lipsum[4]
\begin{exe}
  \item[]\begin{minipage}[t]{0.5\linewidth}
     \ex Left example
  \end{minipage}%
  \begin{minipage}[t]{0.5\linewidth}
     \ex Right example  \label{rightex}
  \end{minipage}
\end{exe}

The right-column example is numbered (\ref{rightex}).

\lipsum[4]

The \ex command works correctly despite the intervening minipage environment. Note the empty \item, and the comment character between the minipage environments to avoid a stray space.

With this method, the vertical spacing is exactly that introduced by gb4e; and the left example is indented the same as ordinary (one-column) examples.

  • Your and David's examples work equally well, and it's not clear to me what's better between embedding exe within minipage and use flushleft (@DavidCarlisle) and embedding minipage within exe and use \item[]. – Sverre Apr 12 '16 at 17:46
  • 1
    Well, it would be hubris to claim that I have a better solution than David Carlisle, but if I'm not mistaken, his will give you the vertical spacing provided by the center environment. It may look like what gb4e inserts, but it strikes me as the wrong approach-- the results will diverge if you customize the behavior of gb4e. – alexis Apr 12 '16 at 20:21
2

The line with the minipages is over-full because of a paragraph indent before the first minipage, and a word space between them.

You could use \noindent\begin{minipage} but here I use center which also sets \parindent to zero and re-adds suitable vertical spacing. I used % to remove the word space between the boxes. (It might be better to have a space between them, in which case they need to be less than .5\linewidth)

enter image description here

\documentclass{article}
\usepackage{lipsum, gb4e}
\begin{document}
\lipsum[4]
\begin{exe}
\ex An exe environment
\end{exe}
\lipsum[4]
\begin{center}
\begin{minipage}[t]{0.5\linewidth}
\begin{exe}
\ex An exe environment
\end{exe}
\end{minipage}%%%
\begin{minipage}[t]{0.5\linewidth}
\begin{exe}
\ex An exe environment
\end{exe}
\end{minipage}
\end{center}
\lipsum[4]
\end{document}
  • 1
    What I also just noticed is that when I added a label after the \ex command, the normal vertical space appeared above the example. Why would that happen? – Sverre Apr 6 '16 at 18:00
  • 1
    @Sverre minipage tries to act like a real page and discards space at the top, but a \label would prevent that space being discarded if it ends up being placed as the first node in the vertical list – David Carlisle Apr 6 '16 at 18:02
  • The problem with center, though, is that it precisely centers the examples. That might be appropriate for some cases, but for my current case, I'd like it to be left aligned, with the same indentation as a normal example has. Is there an easy way to achieve that? Other than inserting spaces like \medskip? – Sverre Apr 6 '16 at 18:06
  • @Sverre since you have two boxes with a total width of \linewidth center flushright or flushleft are all the same thing, none of them produce any horizontal movement. – David Carlisle Apr 6 '16 at 18:21
  • 1
    @Sverre you could use \mbox{}\label{..} or just put the label after some of the text so it is in the first line,not above it – David Carlisle Apr 6 '16 at 18:30

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.