2

I have a driver file for my thesis and all the chapters are included with \input commands. I noticed that only in the sixth chapter the section numbers are false, although they are displayed correctly in the ** table of contents**. I get ** 0.1 Nanoslits ** when I should be getting ** 6.1 Nanoslits **.

The compilation is done on Windows 10 64-bit with TexLive 2016 full installation. After a lot of tinkering I got an example that reproduces the issue and of short length. Here is the MWE and here is the associated class file:

\documentclass[titlepage, footnotes, a4paper]{kuthesismod} 
\usepackage{xspace}
\usepackage{ifxetex}
\ifxetex
    \usepackage{unicode-math} 
    \setmainfont[Numbers=OldStyle,Ligatures=Common,Mapping=tex-text]{Linux Libertine O}
    \setmathfont{Libertinus Math}
\else  
    \usepackage[utf8]{inputenc} 
    \usepackage[T1]{fontenc} 
    \usepackage[oldstyle]{libertine} 
    \usepackage{libertinust1math}
\fi
\usepackage{hyperref} 

\newcommand{\figref}[1]{Figure~\ref{#1}}
\newcommand{\tabref}[1]{Table~\ref{#1}}
\renewcommand{\eqref}[1]{Equation~\ref{#1}}
\newcommand{\chapref}[1]{Chapter~\ref{#1}}
\newcommand*\chem[1]{\ensuremath{\mathrm{#1}}} 
\emergencystretch = 1 em
\begin{document}
    \prelimpages
    \tableofcontents
    \textpages
    \chapter{Introduction}\label{chp:intro}
        \section{Literature Review}

        \section{Thesis Outline}

    \chapter{Background Information}\label{chp:bg}
        \section{Brief review of electromagnetic theory}

        \section{Permittivities of metals}

            \subsection{Lorentz Model}

            \subsection{Drude Model}

            \subsection{Extended Drude Model}

        \section{Plasmons}

            \subsection{Volume Plasmons}

            \subsection{Surface Plasmon Polaritons}

        \chapter{Single Scatterers}\label{chp:singlescat}

        \section{Single Grating}

        \section{Rectangular Nanoslit}

        \section{\texorpdfstring{$\Delta$}{Delta}-antenna} 

    \chapter{SPP beam launcher}\label{chp:sppbeam}

        \section{Reproduction of Hermite-Gauss SPP Beam} 

        \section{Stripe Waveguide Coupling}

    \chapter{Scalar Wave Theory}\label{chp:scalarwave} 

        \section{Antenna Arrays} 

            \subsection{Linear Arrays}

            \subsection{Coupler Design}

        \chapter{Mode Coupling}\label{chp:modecoup}

        \section{Nanoslits}

        \section{\texorpdfstring{$\Delta$-antennas}{Delta-antennas}}

            \subsection{\texorpdfstring{Design with $w_b$ = 500 nm, $h$ = 800 nm }{Design 1}}

            \subsection{\texorpdfstring{Design with $w_b$ = 900 nm, $h$ = 800 nm }{Design 2}}

            \subsection{\texorpdfstring{Design with $w_b$ = 900 nm, $h$ = 800 nm with SPP on air-metal}{Design 3}}

    \chapter{Conclusion and Future Work}\label{chp:conc}

\end{document}
12
  • 3
    And do you think by omitting the relevant code of chapter1.tex we're able to give more than guesses only? ;-)
    – user31729
    May 30, 2017 at 17:19
  • 4
    I think it is because of the Gremlins which are hiding in that file.
    – Skillmon
    May 30, 2017 at 17:33
  • 2
    Which document class do you use? How or were is \chapref defined?
    – Mico
    May 30, 2017 at 19:59
  • 1
    Off-topic: Instead of 80 \si{\micro\meter}, you should write \SI{80}{\micro\meter}. If nothing else, that'll ensure you'll never have a line break between the number and its associated unit.
    – Mico
    May 30, 2017 at 20:01
  • 2
    there is no way that anyone can answer this question, you need to cut the example down so it just needs two or three (small) chapter files and put the full code of all needed files into code sections in the question. May 30, 2017 at 21:24

1 Answer 1

6

xelatex is finding the wrong font. If one load the font by name as done in David's example

This is a more minimal example just using article class, it gives [6] with pdftex and luatex and [0] with xetex.

anyone feel free to pick up this example, if you want to answer (I'll delete this if someone's posted an answer when I next come by:-)

\documentclass{article} 

\ifx\Umathchar\undefined
    \usepackage[utf8]{inputenc} 
    \usepackage[T1]{fontenc} 
    \usepackage[oldstyle]{libertine} 
    \usepackage{libertinust1math}
\else  
    \usepackage{fontspec} 
    \setmainfont[Numbers=OldStyle,Ligatures=Common]{Linux Libertine O}
\fi

\begin{document}


[{\bfseries\slshape 6}]


\end{document}

it uses LinLibertine_RZI.otf instead of the correct LinLibertine_RBI.otf and this hasn't the correct numbers.

\documentclass{article}

\pagestyle{empty}
\begin{document}
\font\test= "[LinLibertine_RBI.otf]:script=latn;language=DFLT;+onum;"

\test 6 1234567890

\font\test= "Linux Libertine O/BI/OT:script=latn;language=DFLT;+onum;"

\test 6 1234567890

\font\test= "[LinLibertine_RZI.otf]:script=latn;language=DFLT;+onum;"

\test 6 1234567890

\end{document}

enter image description here

So you should load at least this font by file name instead than by font name. E.g. by loading it through the libertine package or manually:

\documentclass{article}
\usepackage{fontspec}

\setmainfont[Numbers=OldStyle,Ligatures=Common, 
            BoldItalicFeatures={Extension=.otf},
            BoldItalicFont = LinLibertine_RBI]{Linux Libertine O}
\begin{document}

[{\bfseries\slshape 6}]

\end{document}

Addition

Wrong font means that xelatex finds a different font than lualatex. LinLibertine_RZI.otf is the italic semibold variant of libertine.

But that the font gives wrong old style numbers is not xelatex faults, it happens with luatex too if one force it to use the font. This is cleary a defect in the font and so I added a bug report: https://sourceforge.net/p/linuxlibertine/bugs/331/

2
  • Thanks for the through explanation I will go over it. So is it always safer to load fonts by the exact file name like fontname.ttf or fontname.otf?
    – Vesnog
    May 31, 2017 at 10:12
  • 1
    Yes, if you want complete control file name are better. But by font name is often faster. May 31, 2017 at 10:15

You must log in to answer this question.

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