5

I am using gb4e for glossing examples in my thesis. I want to have the enumeration in such a format that the chapter number precedes the enumeration of samples, such as Example (1.2) which refers to the second example in Chapter 1, and not Example (2). How can this be done?

1 Answer 1

8

The counter for the top level examples in gb4e is xnumi. You can adjust this manually or commands from the chngcntr package which gives a simple interface for this sort of thing. With an up-to-date TeX distribution, you don't need to load the package, since it has been included into the LaTeX kernel. Since the spacing of the examples depends on their format, you also have to tell gb4e to leave enough space for the example number, using the \exewidth command.

To have example numbers restart from 1 each chapter, use \counterwithin{exx}{chapter}. This is much simpler than doing it manually (although I've included that code in the comments just in case.)

\documentclass{book}
%\usepackage{chngcntr} % uncomment this if you have an older distribution
\usepackage{gb4e}
%\renewcommand{\thexnumi}{\thechapter.\arabic{xnumi}} % the manual way
%\makeatletter
%\@addtoreset{exx}{chapter}
%\makeatother
\counterwithin{xnumi}{chapter} % the chngcntr way (preferred)
\counterwithin{exx}{chapter} % reset example counter every chapter
\exewidth{(1.234)} % leave enough room for the example number
\begin{document}
\chapter{}

\begin{exe}
\ex
\label{ex:sample-1}
\gll born be?ettef\={a}q.e yek.i ?az aqv\={a}m.a\v{s} be \v{s}ahr.e per\={a}g moh\={a}jerat kard\\
     Born with.EZ one.INDEF from relatives.CL-3SG to city.EZ Prague move did.3SG \\
\glt `Born moved to the city of Prague with one of his relatives.'
\end{exe}
\end{document}
3
  • Thanks for your answer. I faced another problem that is the counter is not started from 1 in each chapter. The enumeration is continuous throughout the text. I want the counter be set from 1 in each Chapter, such as Example (1.1) and Example (2.1). How can this be done? Thanks in advance.
    – Masood
    Commented May 30, 2013 at 22:25
  • @Masood I've updated my answer.
    – Alan Munn
    Commented May 30, 2013 at 22:54
  • Since this answer seems to have solved your problems, it's helpful to others to "Accept" the answer, by clicking on the checkmark underneath the vote buttons of the question.
    – Alan Munn
    Commented May 31, 2013 at 10:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .