1

Trying to use a template from overleaf, which worked perfectly in English. But adding babel for Spanish is messing up the document.

I'm getting an error if I try to add a \subsection{}.

I've looked at other questions which mention the conflicts between babel, hyperref and appendix and I believe that there's something similar going on here but I just can't figure it out.

The things that have helped me remove the error are getting rid of the hyperref package or not inserting a table of contents.

Here's the most minimal I could take the template to reproduce the error (I think). I'm using xelatex, not sure if that tells you anything.

\documentclass[
    a4paper, % Paper size, use either a4paper or letterpaper
    12pt, % Default font size, the template is designed to look good at 12pt so it's best not to change this
]{article}

\usepackage[utf8]{inputenc} % Required for inputting international characters \usepackage[T1]{fontenc} % Output font encoding for international characters \usepackage[spanish]{babel}

%---------------------------------------------------------------------------------------- % REQUIRED PACKAGES AND MISC CONFIGURATIONS %----------------------------------------------------------------------------------------

\usepackage{etoolbox} % Required for conditional logic and easily changing commands

\newtoggle{unnumberedsections} % Create toggle for a class option \settoggle{unnumberedsections}{false} % Default value for the class option \DeclareOption{unnumberedsections}{\settoggle{unnumberedsections}{true}} % Set the class option toggle if the class option was used in the template

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} % Pass through any extra options specified to the base class \ProcessOptions\relax % Process class options

\usepackage[document]{ragged2e} % Left align all text in the document (i.e. have a ragged right margin)

\usepackage{lastpage} % Required to determine the total number of pages

\AtBeginEnvironment{quote}{\itshape\rmfamily} % Style quotations

\usepackage{appendix} % Required for the appendices section

\usepackage{float} % Allows more precisely positioning floats e.g. \begin{figure}[H]

%---------------------------------------------------------------------------------------- % SECTIONS %----------------------------------------------------------------------------------------

\usepackage{titlesec} % Required for modifying sections

\iftoggle{unnumberedsections}{ % Conditional logic for the unnumbered sections class options \setcounter{secnumdepth}{0} % Don't number sections at any level }{ \setcounter{secnumdepth}{3} % Number sections down to subsubsections }

\titleformat {\section} % Section type being modified [block] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\raggedright\LARGE\bfseries} % Text formatting of the whole section, i.e. label and title {\thesection} % Section label (e.g. number) and its formatting {5pt} % Horizontal space between the section label and title {} % Code before the section title [] % Code after the section title

\titlespacing*{\section}{0pt}{\baselineskip}{4pt} % Spacing around section titles, the order is: left, before and after

%------------------------------------------------

\titleformat {\subsection} % Section type being modified [block] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\raggedright\large\bfseries} % Text formatting of the whole section, i.e. label and title {\thesubsection} % Section label (e.g. number) and its formatting {5pt} % Horizontal space between the section label and title {} % Code before the section title [] % Code after the section title

\titlespacing*{\subsection}{0pt}{0.75\baselineskip}{4pt} % Spacing around section titles, the order is: left, before and after

%------------------------------------------------

\titleformat {\subsubsection} % Section type being modified [block] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\raggedright\bfseries\normalsize} % Text formatting of the whole section, i.e. label and title {\thesubsubsection} % Section label (e.g. number) and its formatting {5pt} % Horizontal space between the section label and title {} % Code before the section title [] % Code after the section title

\titlespacing*{\subsubsection}{0pt}{0.5\baselineskip}{0pt} % Spacing around section titles, the order is: left, before and after

%------------------------------------------------

\titleformat {\paragraph} % Section type being modified [runin] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\bfseries} % Text formatting of the whole section, i.e. label and title {} % Section label (e.g. number) and its formatting {0pt} % Horizontal space between the section label and title {} % Code before the section title [~~~~] % Code after the section title

\titlespacing*{\paragraph}{0pt}{0pt}{0pt} % Spacing around section titles, the order is: left, before and after

% %---------------------------------------------------------------------------------------- % % TABLE OF CONTENTS % %----------------------------------------------------------------------------------------

\usepackage{titletoc} % Required for manipulating the table of contents

\setcounter{tocdepth}{2} % Show entries in the table of contents down to subsections

\renewcommand{\contentsname}{Table of Contents} % Rename the table of contents section heading

\titlecontents{section} % Section type being modified [0pt] % Left indentation {\vspace{-2pt}} % Before code {\textsb{\thecontentslabel}~~\textsb} % Formatting of numbered sections of this type {\textsb} % Formatting of numberless sections of this type {\titlerule*[6pt]{.}\textsb{\contentspage}} % Formatting of the filler to the right of the heading and the page number [\vspace{2pt}] % After code

%------------------------------------------------

\titlecontents{subsection} % Section type being modified [0.5cm] % Left indentation {\vspace{-8pt}} % Before code {\textsb{\thecontentslabel}~~} % Formatting of numbered sections of this type {} % Formatting of numberless sections of this type {\titlerule*[6pt]{.}\contentspage} % Formatting of the filler to the right of the heading and the page number [] % After code

%------------------------------------------------

\titlecontents{subsubsection} % Section type being modified [1.35cm] % Left indentation {\vspace{-4pt}} % Before code {\textsb{\thecontentslabel}~~} % Formatting of numbered sections of this type {} % Formatting of numberless sections of this type {\titlerule*[6pt]{.}\contentspage} % Formatting of the filler to the right of the heading and the page number [] % After code

%---------------------------------------------------------------------------------------- % LINKS %----------------------------------------------------------------------------------------

\usepackage{hyperref}

\hypersetup{ colorlinks=true, % Whether to color the text of links urlcolor=red, % Color for \url and \href links linkcolor=black, % Color for \nameref links citecolor=black, % Color of reference citations }

%---------------------------------------------------------------------------------------- % MAIN DOCUMENT %----------------------------------------------------------------------------------------

\begin{document}

%---------------------------------------------------------------------------------------- % TABLE OF CONTENTS %----------------------------------------------------------------------------------------

\thispagestyle{empty}

\tableofcontents % Output the table of contents, automatically generated from the section commands used in the document

\section{Hola}

Hola

\subsection{No sirve}

\end{document}

This is the error I get

Undefined control sequence.
<argument> ...me system@active~\endcsname \textsb

l.2 ...section}{\numberline {1}Hola}{1}{section.1}

Undefined control sequence. <argument> \textsb {\thecontentslabel }~~ l.3 ...umberline {1.1}No sirve}{1}{subsection.1.1} %

Please help, I'm going insane!!

migueldva
  • 251
  • 1
    well nothing defines \textsb. What do you expect it to do? Apart from this: don't use inputenc and fontenc with xelatex. And better load babel like this: \usepackage[spanish,es-notilde]{babel}. – Ulrike Fischer Jul 16 '22 at 08:38
  • To expand on the other answers a bit: \textsb{...} is a command in several packages to switch to semibold weight, like the standard \textbf{...} for boldface and \textmd{...} for medium weight. However, it’s not defined in the LaTeX kernel, or fontspec. – Davislor Jul 16 '22 at 15:33

1 Answers1

2

Define \textsb. (After fontspec-italic-small-caps-with-semi-bold and also a previous answer)

a

% !TeX TS-program = xelatex

\documentclass[ a4paper, % Paper size, use either a4paper or letterpaper 12pt, % Default font size, the template is designed to look good at 12pt so it's best not to change this ]{article}

%\usepackage[utf8]{inputenc} % Required for inputting international characters %\usepackage[T1]{fontenc} % Output font encoding for international characters

\usepackage[spanish,es-notilde]{babel}% changed <<<<<<<<<<<<<<<<

%% https://tex.stackexchange.com/questions/592364/fontspec-italic-small-caps-with-semi-bold %% https://tex.stackexchange.com/a/264666/161015 %****************************************************** added <<<<<<<<<<<<<<<<<<< \usepackage{fontspec}

\setmainfont{Linux Libertine O}[ BoldFont=* Bold, BoldItalicFont=* Bold Italic, FontFace = {sb}{n}{* Semibold}, FontFace = {sb}{it}{* Semibold Italic}, ]

\DeclareRobustCommand{\sbseries}{\fontseries{sb}\selectfont} \DeclareTextFontCommand{\textsb}{\sbseries} %******************************************************

%---------------------------------------------------------------------------------------- % REQUIRED PACKAGES AND MISC CONFIGURATIONS %----------------------------------------------------------------------------------------

\usepackage{etoolbox} % Required for conditional logic and easily changing commands

\newtoggle{unnumberedsections} % Create toggle for a class option \settoggle{unnumberedsections}{false} % Default value for the class option \DeclareOption{unnumberedsections}{\settoggle{unnumberedsections}{true}} % Set the class option toggle if the class option was used in the template

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} % Pass through any extra options specified to the base class \ProcessOptions\relax % Process class options

\usepackage[document]{ragged2e} % Left align all text in the document (i.e. have a ragged right margin)

\usepackage{lastpage} % Required to determine the total number of pages

\AtBeginEnvironment{quote}{\itshape\rmfamily} % Style quotations

\usepackage{appendix} % Required for the appendices section

\usepackage{float} % Allows more precisely positioning floats e.g. \begin{figure}[H]

%---------------------------------------------------------------------------------------- % SECTIONS %----------------------------------------------------------------------------------------

\usepackage{titlesec} % Required for modifying sections

\iftoggle{unnumberedsections}{ % Conditional logic for the unnumbered sections class options \setcounter{secnumdepth}{0} % Don't number sections at any level }{ \setcounter{secnumdepth}{3} % Number sections down to subsubsections }

\titleformat {\section} % Section type being modified [block] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\raggedright\LARGE\bfseries} % Text formatting of the whole section, i.e. label and title {\thesection} % Section label (e.g. number) and its formatting {5pt} % Horizontal space between the section label and title {} % Code before the section title [] % Code after the section title

\titlespacing*{\section}{0pt}{\baselineskip}{4pt} % Spacing around section titles, the order is: left, before and after

%------------------------------------------------

\titleformat {\subsection} % Section type being modified [block] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\raggedright\large\bfseries} % Text formatting of the whole section, i.e. label and title {\thesubsection} % Section label (e.g. number) and its formatting {5pt} % Horizontal space between the section label and title {} % Code before the section title [] % Code after the section title

\titlespacing*{\subsection}{0pt}{0.75\baselineskip}{4pt} % Spacing around section titles, the order is: left, before and after

%------------------------------------------------

\titleformat {\subsubsection} % Section type being modified [block] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\raggedright\bfseries\normalsize} % Text formatting of the whole section, i.e. label and title {\thesubsubsection} % Section label (e.g. number) and its formatting {5pt} % Horizontal space between the section label and title {} % Code before the section title [] % Code after the section title

\titlespacing*{\subsubsection}{0pt}{0.5\baselineskip}{0pt} % Spacing around section titles, the order is: left, before and after

%------------------------------------------------

\titleformat {\paragraph} % Section type being modified [runin] % Section layout type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame {\bfseries} % Text formatting of the whole section, i.e. label and title {} % Section label (e.g. number) and its formatting {0pt} % Horizontal space between the section label and title {} % Code before the section title [~~~~] % Code after the section title

\titlespacing*{\paragraph}{0pt}{0pt}{0pt} % Spacing around section titles, the order is: left, before and after

% %---------------------------------------------------------------------------------------- % % TABLE OF CONTENTS % %----------------------------------------------------------------------------------------

\usepackage{titletoc} % Required for manipulating the table of contents

\setcounter{tocdepth}{2} % Show entries in the table of contents down to subsections

\renewcommand{\contentsname}{Table of Contents} % Rename the table of contents section heading

\titlecontents{section} % Section type being modified [0pt] % Left indentation {\vspace{-2pt}} % Before code {\textsb{\thecontentslabel}~~} % Formatting of numbered sections of this type {\textsb} % Formatting of numberless sections of this type {\titlerule*[6pt]{.}\textsb{\contentspage}} % Formatting of the filler to the right of the heading and the page number [\vspace{2pt}] % After code

%------------------------------------------------

\titlecontents{subsection} % Section type being modified [0.5cm] % Left indentation {\vspace{-2pt}} % Before code <<<<<<<<<<<<<<<<<<< {\textsb{\thecontentslabel}~~} % Formatting of numbered sections of this type {} % Formatting of numberless sections of this type {\titlerule*[6pt]{.}\contentspage} % Formatting of the filler to the right of the heading and the page number [] % After code

%------------------------------------------------

\titlecontents{subsubsection} % Section type being modified [1.35cm] % Left indentation {\vspace{-4pt}} % Before code {\textsb{\thecontentslabel}~~} % Formatting of numbered sections of this type {} % Formatting of numberless sections of this type {\titlerule*[6pt]{.}\contentspage} % Formatting of the filler to the right of the heading and the page number [] % After code

%---------------------------------------------------------------------------------------- % LINKS %----------------------------------------------------------------------------------------

\usepackage{hyperref}

\hypersetup{ colorlinks=true, % Whether to color the text of links urlcolor=red, % Color for \url and \href links linkcolor=black, % Color for \nameref links citecolor=black, % Color of reference citations }

%---------------------------------------------------------------------------------------- % MAIN DOCUMENT %----------------------------------------------------------------------------------------

\begin{document}

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\thispagestyle{empty} 

\tableofcontents % Output the table of contents, automatically generated from the section commands used in the document

\section{Hola}

Hola

\textsb{Hola}

\subsection{No sirve}

\end{document}

Simon Dispa
  • 39,141