
Estou usando XeTeX
para editar um documento no qual estou tentando usar titlesec
e titling
para definir uma fonte diferente para alguns títulos.
Estou usando a abordagem sugerida comoresponder a uma pergunta semelhante, mas até agora meu sucesso é realmente parcial.
Os section
títulos e subsection
alteram a fonte conforme desejado, mas o chapter
título ignora a configuração.
Aqui está um trecho do meu 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}
A configuração do capítulo é algo que tentei imitando a solução fornecida no link acima. Aprendi que *
é necessário remover de alguma forma, pois easy mode
não funcionaria com títulos de capítulos. Ainda não descobri o porquê. Mas a verdade é que remover o asterisco também elimina o erro... mas parece não funcionar em relação à configuração da fonte.
Alguma ideia?
Obrigado :)
Editar: encontrei um erro muito bobo, que me levou a uma solução (parcial) e apareceu um novo erro. Acabei de configurar \documentclass{book}
e agora o renderizador tenta colocar a fonte desejada, mas titlesec
gera um erro:
Titles must not be nested
O código LaTeX é 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}
O chapter
título é aquele que aciona o erro titlesec.
Responder1
A linha
\titleformat{\chapter}{\LARGE\headingfont}
é o culpado. A sintaxe está errada. O certo é
\titleformat{\chapter}[display]
{\huge\headingfont}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
Então, o MWE (usei Arial em vez de Armata porque não tenho essa fonte 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}
produz a seguinte saída