1

I am making a document with glosses (using package gb4e) and sections. The glosses correspond to certain numbers within certain chapters, but these chapters do not correspond to the sections I'm using; those depend on a certain date. See the MWE.

How can I reset the glosses counter at places of my own liking. Until now I used the chngcntr package with the command \counterwithin{exx}{section}, but when the sections and 'chapters' (when the counter has to be reset) do not correspond, I'm getting into trouble.

Using a \section* does not work, since the counter continues.

\documentclass{article}

\usepackage{gb4e}
\usepackage{chngcntr}
\counterwithin{exx}{section}

\begin{document}

\section{Yesterday}
\begin{center}{\scshape\large Chapter 1}\end{center}
\begin{exe} 
\ex \gll This is a sentence we read yesterday\\
Este es una frase [nos] leer ayer\\

\section{Today}                
\ex \gll This way the counter continues, but it isn't preferable either\\
Este manera el contador continuar, pero lo no.es preferible tampoco\\
\end{exe}

\begin{center}{\scshape\large Chapter 2}\end{center}
\begin{exe} 
\ex \gll This.one should.be number 1 again\\
Este ser\'{i}a numero 1 de.nuevo\\ 
\end{exe}

\section{Tomorrow}
\begin{exe}
\ex \gll I want this to be number 2.\\
[yo] quere este a ser numero 2\\

\begin{center}{\scshape\large Chapter 3}\end{center}
\ex \gll And this is a 1.\\
Eta hau da bat 1\\
\end{exe}
\end{document}

As you can see, the \counterwithin{exx}{section} is not at all handy here, but the first times the chapters and dates more or less corresponded.

3
  • 2
    I don't really understand what you are trying to do. You can say \setcounter{exx}{0} at appropriate points and that will reset the counter provided, I think, you are not in the middle of an exe environment where it seems to have no effect. But I don't understand what you are doing with the fake chapters and sectioning. What is not preferable? Why not use real chapters? Why start a chapter within a section? I basically get a mess and I have very little idea how to clean it up.
    – cfr
    Apr 12, 2014 at 1:00
  • Well, that is maybe not what I thought to be needed, but it really solves the problem. I didn't thought it was that simple.
    – Jopie
    Apr 13, 2014 at 16:23
  • @jopie: I've added another (possible) solution some days ago. Could you give some feedback, please?
    – user31729
    Mar 1, 2015 at 9:33

1 Answer 1

2

The strange fact that faked chapters come in between sections does not simplify the whole procedure.

I my opinion, the \section command should not start within an exe environment. Doing this, a macro \centredchapter with automatic titles and counting does the job, if \counterwithin{exx}{chapter} is used.

A reset via \setcounter{exx}{0} where appropiate can done anyway.

\documentclass{article}

\usepackage{gb4e}
\usepackage{chngcntr}
\newcounter{chapter}
\counterwithin{exx}{chapter}


\newcommand{\centredchapter}{%
  \refstepcounter{chapter}%
  \begin{center}\scshape\large Chapter~\thechapter\end{center}
}%


\begin{document}

\section{Yesterday}
\centredchapter
%\begin{center}{\scshape\large Chapter 1}\end{center}
\begin{exe} 
\ex \gll This is a sentence we read yesterday\\
Este es una frase [nos] leer ayer\\
\end{exe}
\section{Today}                
\begin{exe}
\ex \gll This way the counter continues, but it isn't preferable either\\
Este manera el contador continuar, pero lo no.es preferible tampoco\\
\end{exe}
\centredchapter
%\begin{center}{\scshape\large Chapter 2}\end{center}
\begin{exe} 
\ex \gll This.one should.be number 1 again\\
Este ser\'{i}a numero 1 de.nuevo\\ 
\end{exe}

\section{Tomorrow}
\begin{exe}
\ex \gll I want this to be number 2.\\
[yo] quere este a ser numero 2\\
\end{exe}
\centredchapter
\begin{exe}
\ex \gll And this is a 1.\\
Eta hau da bat 1\\
\end{exe}

\end{document}

enter image description here

You must log in to answer this question.

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