5

I'm using proportional numbers in my document. But in gb4e's example numbers, I would like to have monospaced numbers, so that the width of the example parenthesis remains the same throughout my document.

In the MWE below, I would in other words like to have the example numbers (1) and (2) monospaced, so that their width is the same, but the number sequences 021345 should use proportional numbers.

\documentclass{article}
\usepackage{fontspec}
    \setmainfont[Numbers = {OldStyle, Proportional}]{Linux Libertine O}
\usepackage{gb4e}
    \exewidth{(9)} % change the default (999) to one digit (9)
\begin{document}
\begin{exe}
\ex 012345
\ex 012345
\end{exe}
\end{document}

enter image description here

4

You can disable the pnum feature when the label is being created:

\documentclass{article}
\usepackage{fontspec}
\usepackage{gb4e}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@exe}
  {(\thexnumi)}
  {(\addfontfeatures{RawFeature=-pnum}\thexnumi)}
  {}{}
\makeatother

\setmainfont[Numbers = {OldStyle, Proportional}]{Linux Libertine O}

\exewidth{(9)} % change the default (999) to one digit (9)

\begin{document}
\begin{exe}
\ex 012345
\ex 012345
\end{exe}
\end{document}

enter image description here

  • I don't think you want to change the with parameter to (9) because that will left align the numbers rather than right align them (noticeable when the numbers have more than one digit). – Alan Munn Mar 15 '15 at 23:55
  • @AlanMunn That's the OP's choice. – egreg Mar 15 '15 at 23:57
  • In my actual document, this creates an error message Command \@ already defined because I have defined commands such as \@confname elsewhere (see this question). Is there an easy fix to this? – Sverre Mar 17 '15 at 16:21
  • 1
    @Sverre Commands like \@confname should be defined between \makeatletter and \makeatother – egreg Mar 17 '15 at 16:26
  • @AlanMunn I use \exewidth{(9)} when my document has $<10$ \ex commands and \exewidth{(99)} when it has $<100 >9$. – Sverre Mar 17 '15 at 16:35
0

I'm no expert at gb4e and it looks so complicated that this solution might cause problems in a more realistic document, but it works for your example.

\documentclass{article}
\usepackage{fontspec}
    \setmainfont[Numbers = {OldStyle, Proportional}]{Linux Libertine O}
\usepackage{gb4e}
    \exewidth{(9)} % change the default (999) to one digit (9)
% ----------------------------  
\makeatletter
\renewcommand{\thexnumi}{\makebox[.6em][c]{\@xsi{xnumi}}}
\makeatother
% ----------------------------
\begin{document}
\begin{exe}
\ex 012345
\ex 012345
\end{exe}
\end{document}

The idea is to put the example numbers into a fixed width box.

enter image description here

  • 1
    I'd be wary of redefining \thexnumi in that way, because it's used also for cross-references. – egreg Mar 15 '15 at 21:27
  • @egreg, it seems to be ok - you just get \newlabel{eg}{{\makebox [.6em][c]{1}}{1}} in the .aux file which just sets the referenced numbers in a box. But your way looks more robust. – Thruston Mar 15 '15 at 23:24

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.