3

I am using \ex to enumerate my examples in the text. Sometimes I would like to have the example start without line feed, i.e. in the same line. (for instance if the sentence is short, to save space) So I would like to have the output:

"Balala, as in (2) example. Blablabal"

And the exe environment is producing

"Balala, as in

(2) example.

Blablabal"

Aslo for items in the xlist it would be nice to put the next to each other, so (1) a) Blaa. b) blla.

I was not able to find how it is possible. Nothing seems to work for me. Does anyone have a solution?

I removed other packages. I thought there should be a way to adjust it. I do not know any alternative that would allow for what I need.

\documentclass[11pt,a4paper]{article}
\usepackage{gb4e}

\begin{document}

Consider (\ref{exe:0}).

\begin{exe}
\ex\label{exe:some}
\begin{xlist}
\ex \emph{Some...}\label{exe:0}
\ex \emph{Not ...} \label{exe:1} %% I want to have them next to each other
\end{xlist}    
\end{exe}

Blabla:

\begin{exe}    
\ex \emph{Some...} % I want to have this "inline"   
\end{exe} 
\end{document}
  • Can you provide an example, what you like to achieve, please? In form of small, complete document starting with \documentclass{...} and ending with \end{document}? With out it the question is unclear to me. Welcome to TeX.SE. – Zarko Nov 1 '16 at 0:10
  • 1
    Hi and welcome to TeX.se. Please show a minimal example of what you are doing. gb4e is not designed for inline examples. – Alan Munn Nov 1 '16 at 0:11
3

For putting sets of examples side by side you can use the multicol package. The downside of this is that it numbers the examples in a way that you might not like. This is how the package works, so there is no good way around it. For a better method, see the following question:

For inline examples, here is a way to do this using enumitem to create the inline list but using the example counter from gb4e. It only works for the top level numbering (i.e., you can't have sublists inside inline examples.) It also won't support glossed examples (for obvious reasons.) I don't really think this is a good way of doing examples, in all honesty.

\documentclass[11pt,a4paper]{article}
\usepackage{gb4e}
\usepackage{multicol}
\usepackage[inline]{enumitem}
\newlist{inlineex}{enumerate*}{1}
\usepackage{calc}
\newcommand{\stepexx}{\value{exx}+1}
\setlist[inlineex,1]{label=(\protect\refstepcounter{exx}\arabic*),ref=(\arabic*),start=\stepexx}
\begin{document}
We can use \texttt{multicol} to put examples in columns. Consider (\ref{exe:0}).
 \begin{exe} 
\begin{multicols}{2}
 \ex\label{exe:some}
 \begin{xlist}
 \ex \emph{Some...}\label{exe:0} 
 \ex \emph{Not ...} \label{exe:1}
 \ex \emph{Third}
 \ex \emph{Fourth} %% I want to have them next to each other 
 \end{xlist}
\end{multicols} 
 \end{exe}


\begin{exe}\ex foo\end{exe} 
This is some text that contains an inline example
\begin{inlineex}
\item \emph{Some inline example.}\label{exe:inline3}
\item \emph{Another inline example.}\label{exe:inline4} % I want to have this "inline"
\end{inlineex}
This is the end of the paragraph with the inline example.
\begin{exe}
\ex This is an example to show the numbers are correct.
\ex Another one
\end{exe}
As you can see references to  \ref{exe:inline4} inline examples \ref{exe:inline3} work too. Unlike \texttt{gb4e} labels they don't need to be wrapped in parentheses.
\begin{inlineex}
\item \emph{This is one last inline example.}
\end{inlineex} And this is the last sentence.
\begin{exe}
\ex An example.
\ex Another one.
\end{exe}
\end{document}

output of code

  • Thank you! I am currently checking the enumitem package, would there be a way to do it also for subslist? – Maria Nov 2 '16 at 11:42
  • Inside the inlineex list you can use a normal \begin{enumerate*}[label=\alph*.]\item inline subex\item inline subex\end{enumerate*} but this will become completely unreadable quite quickly, and won't support references. But seriously, don't do this. – Alan Munn Nov 2 '16 at 11:47

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.