1

I am trying to format the titles of a document using the titlesec package.

Overall I want:

  • Chapter numbers in romans, inline chapter number and chapter name preceded by "Capítulo"
  • Sections, subsections, and so on with normal font size
  • sections, subsections,..., figures, tables and equations with arabic numbers

So far I have the following block of code

\documentclass{report}
\usepackage{titlesec}
\titleformat*{\section}{\normalsize\bfseries}
\titleformat*{\subsection}{\normalsize\bfseries}
\titleformat*{\subsubsection}{\normalsize\bfseries}
\titleformat*{\paragraph}{\normalsize\bfseries}
\titleformat*{\subparagraph}{\normalsize\bfseries}
\titleformat{name=\chapter,numberless}[hang]{\normalfont \bfseries\centering\scshape\LARGE}{}{1pt}{#1}[] 
\titleformat{\chapter}[hang]{\normalfont \bfseries\centering\scshape\LARGE}{}{1pt}{Capítulo \thechapter. #1}{}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\begin{document}
\chapter{Test chapter}
\section{Test section}
\subsection{Test section}
\subsubsection{Test section}
\paragraph{Test section}
\subparagraph{Test section}

Which returns an Illegal parameter number in definition of \ttlf@chapter/* error, setting the option [explicit] in the titlesec package makes the chapter formating and section numbering work but return a bunch of errors if I add the \titleformat* parts.

1 Answer 1

5

The \titleformat command does not expect any parameter (#1) unless the explicit option is used. By removing both #1 from your code (and adding an \end{document} line), I get without errors the expected result:

If you do want to use the explicit option, the same output is obtained with the following code.

\documentclass{report}
\usepackage[explicit]{titlesec}
\titleformat{\section}{\normalsize\bfseries}{}{0pt}{\thesection\quad#1}[]
\titleformat{\subsection}{\normalsize\bfseries}{}{0pt}{\thesubsection\quad#1}[]
\titleformat{\subsubsection}{\normalsize\bfseries}{}{0pt}{#1}[]
\titleformat{\paragraph}{\normalsize\bfseries}{}{0pt}{#1}[]
\titleformat{\subparagraph}{\normalsize\bfseries}{}{0pt}{#1}[]
\titleformat{name=\chapter,numberless}[hang]{\normalfont \bfseries\centering\scshape\LARGE}{}{1pt}{#1}[] 
\titleformat{\chapter}[hang]{\normalfont \bfseries\centering\scshape\LARGE}{}{1pt}{Capítulo \thechapter. #1}{}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\begin{document}
\chapter{Test chapter}
\section{Test section}
\subsection{Test section}
\subsubsection{Test section}
\paragraph{Test section}
\subparagraph{Test section}
\end{document}

You must log in to answer this question.

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