
Lo estoy usando XeTeX
para editar un documento en el que intento usar titlesec
y titling
configurar una fuente diferente para algunos títulos.
Estoy usando el enfoque sugerido comoresponder a una pregunta similar, pero hasta ahora mi éxito es realmente parcial.
Los títulos section
y subsection
cambian la fuente según se desee, pero el chapter
título ignora la configuración.
Aquí hay un fragmento de mi código.
%%% to allow custom headings
\usepackage{titlesec}
% to change titles font family
\usepackage{titling}
%%% declare fonts and set some formats
% fontspec to use non-latex with xetex
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}
% font declaration and title settings
\newfontfamily\headingfont[]{Armata}
\titleformat{\chapter}{\LARGE\headingfont}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}
La configuración del capítulo es algo que probé mientras imitaba la solución proporcionada en el enlace anterior. Aprendí que *
es necesario eliminarlo de alguna manera, ya que easy mode
no funcionaría con los títulos de los capítulos. Todavía no encontré por qué. Pero la verdad es que eliminar el asterisco también elimina el error... pero no parece funcionar con respecto a la configuración de la fuente.
¿Algunas ideas?
Gracias :)
Editar: encontré un error realmente tonto que me llevó a una solución (parcial) y apareció un nuevo error. Acabo de configurar \documentclass{book}
y ahora el renderizador intenta poner la fuente deseada, pero titlesec
arroja un error:
Titles must not be nested
El código LaTeX es este:
\begin{document}
\chapter{First Chapter}
The title above does not show any font.
\section{First Section}
Works as desired.
\subsection{Subsection}
Hiya! This also shows up as expected.
\subsubsection{Subsubsection}
We have not declared a titleformat for this heading, and so it is shown with the default font.
\section{Second section}
Repeating the success
\end{document}
El chapter
título es el que desencadena el error titlesec.
Respuesta1
La línea
\titleformat{\chapter}{\LARGE\headingfont}
es el culpable. La sintaxis es incorrecta. El correcto es
\titleformat{\chapter}[display]
{\huge\headingfont}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
Entonces, el MWE (he usado Arial en lugar de Armata ya que no tengo esa fuente instalada):
\documentclass{book}
%%% to allow custom headings
\usepackage{titlesec}
% to change titles font family
\usepackage{titling}
%%% declare fonts and set some formats
% fontspec to use non-latex with xetex
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}
% font declaration and title settings
\newfontfamily\headingfont[]{Arial}
\titleformat{\chapter}[display]
{\huge\headingfont}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}
\begin{document}
\chapter{First Chapter}
The title above does not show any font.
\section{First Section}
Works as desired.
\subsection{Subsection}
Hiya! This also shows up as expected.
\subsubsection{Subsubsection}
We have not declared a titleformat for this heading, and so it is shown with the default font.
\section{Second section}
Repeating the success
\end{document}
produce el siguiente resultado