5

I am using the package gb4e for managing linguistics examples. I want two things:

  1. The examples should be numbered according to the chapter in which they appear, e.g. the first example of ch. 2 should be (2.1), etc.
  2. the examples in footnotes should be numbered with roman numbers ( (i), (ii), ...).

The way to achieve both results individually are described here and here respectively. However, if I try to use the two solutions together, only the footnote numbering works but the examples in the body of text go back to being numbered normally with no reference to the chapter, e.g. as (1), (2), etc...

I am probably missing something very stupid. Any advice on this?

Here's a minimal example:

    \documentclass[a4paper,11pt]{report}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{gb4e}
\noautomath
\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
\makeatletter
\pretocmd{\@footnotetext}{
    \@noftnotefalse\setcounter{fnx}{0}%
    \renewcommand{\thexnumi}{\roman{xnumi}}
}{}{}
\apptocmd{\@footnotetext}{
    \@noftnotetrue
    \renewcommand{\thexnumi}{\arabic{xnumi}}
}{}{}
\@ifpackageloaded{bidi}{%
    \pretocmd{\@LTRfootnotetext}{
        \@noftnotefalse\setcounter{fnx}{0}%
        \renewcommand{\thexnumi}{\roman{xnumi}}
    }{}{}
    \apptocmd{\@LTRfootnotetext}{
        \@noftnotetrue
        \renewcommand{\thexnumi}{\arabic{xnumi}}
    }{}{}
}
\makeatother

\begin{document}
\chapter{Test}
    This is a test.\footnote{Blabla \begin{exe}
            \ex Some text.
        \end{exe}}

    \begin{exe}
        \ex BlaBlaBla.
    \end{exe}

\end{document}

1 Answer 1

5

Apparently resetting arabic numerals at the end of each footnote also resets the numbering scheme. You can append this setting to \@footnotetext to keep the setting (note that you also need the global commands for the case that you have regular examples before the first footnote example.

Side note: if you don't use polyglossia you don't need the bidi part of the footnote modifications.

MWE:

\documentclass[a4paper,11pt]{report}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{gb4e}
\noautomath
\counterwithin{xnumi}{chapter} % the chngcntr way (preferred)
\counterwithin{exx}{chapter} % reset example counter every chapter
\exewidth{(1.234)}

\makeatletter
\pretocmd{\@footnotetext}{%
\@noftnotefalse\setcounter{fnx}{0}%
\renewcommand{\thexnumi}{\roman{xnumi}}%
}{}{}
\apptocmd{\@footnotetext}{%
\@noftnotetrue%
\renewcommand{\thexnumi}{\arabic{xnumi}}%
\counterwithin{xnumi}{chapter}% Reset regular numbering after footnote modifications
    \counterwithin{exx}{chapter}%
    \exewidth{(1.234)}%
}{}{}
\makeatother

\begin{document}
\chapter{Test}
    \begin{exe}
        \ex First example.
    \end{exe}
    This is a test\footnote{Blabla \begin{exe}
            \ex Some text.
        \end{exe}}with the footnote in between.

    \begin{exe}
        \ex BlaBlaBla.
    \end{exe}
\end{document}

Result:

enter image description here

1
  • 1
    @Luca: Consider accepting the answer by clicking onto the checkmark Commented Jan 16, 2017 at 16:50

You must log in to answer this question.

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