当图像标题中有变音符号时,\caption 会出现一个令人困扰的问题。变音符号显示正常,但在这种情况下,标题本身会左对齐,而不是居中。知道为什么我的环境会导致标题出现这种情况吗?
这是我正在使用的相关文档类。
\ProvidesClass{phdthesis}
%%
%% Base document style and options.
%%
\LoadClass[12pt,a4paper,titlepage,twoside,openright,fleqn]{book}
%%
%% Page margins
%%
%\RequirePackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=12pt,a4paper]{geometry}
%%
%% Color definitions
%%
\RequirePackage[svgnames]{xcolor}
\definecolor{mainColor}{RGB}{206,0,124} % You may redefine mainColor to suit your needs
%%
%% Font settings
%%
\RequirePackage[utf8]{inputenc}
\RequirePackage{fix-cm}
\RequirePackage[OT1,T1]{fontenc}
\RequirePackage[scaled]{helvet}
\renewcommand*\familydefault{\sfdefault}
\RequirePackage{microtype}
%\RequirePackage[english]{babel}
\RequirePackage[brazilian]{babel}
\RequirePackage[autostyle]{csquotes}
%% Bibliography settings
\RequirePackage[style=alphabetic,sorting=nyt,sortcites=true,autopunct=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\defbibheading{bibempty}{}
%% Index settings
\RequirePackage{calc}
\RequirePackage{makeidx}
\makeindex
%%
%% Title page
%%
\RequirePackage{pdfpages}
\RequirePackage{graphicx}
\RequirePackage{tikz}
\RequirePackage{eso-pic}
\newcommand{\printtitlepage}[3]{%
\begingroup
\thispagestyle{empty}
\AddToShipoutPicture*{\put(0.5,0.5){\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#1}}} % Image background
\centering
\vspace*{9cm}
\par\normalfont\fontsize{35}{35}\sffamily\selectfont
{#2}\par % Document title
\vspace*{1cm}
{\Huge {#3}}\par % Author name
\endgroup}
\newcommand{\HRule}[1]{\hfill \rule{0.2\linewidth}{#1}}
%% Main table of contents
\RequirePackage{titlesec}
\RequirePackage{titletoc}
\contentsmargin{0cm} % Removes the default margin
% Chapter text styling
\titlecontents{chapter}[1.25cm] % Indentation
{\addvspace{15pt}\large\sffamily\bfseries} % Spacing and font options for chapters
{\color{mainColor!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{mainColor}} % Chapter number
{}
{\color{mainColor!60}\normalsize\sffamily\bfseries\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
% Section text styling
\titlecontents{section}[1.25cm] % Indentation
{\addvspace{5pt}\sffamily\bfseries} % Spacing and font options for sections
{\contentslabel[\thecontentslabel]{1.25cm}} % Section number
{}
{\sffamily\hfill\color{black}\thecontentspage} % Page number
[]
% Subsection text styling
\titlecontents{subsection}[1.25cm] % Indentation
{\addvspace{1pt}\sffamily\small} % Spacing and font options for subsections
{\contentslabel[\thecontentslabel]{1.25cm}} % Subsection number
{}
{\sffamily\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
[]
%% Chapter table of contents
% Section text styling
\titlecontents{lsection}[0em] % Indendating
{\footnotesize\sffamily} % Font settings
{}
{}
{}
% Subsection text styling
\titlecontents{lsubsection}[.5em] % Indentation
{\normalfont\footnotesize\sffamily} % Font settings
{}
{}
{}
%%
%% Page headers
%%
\RequirePackage{fancyhdr} % Required for header and footer configuration
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} % Section text font settings
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Font setting for the page number in the header
\fancyhead[LO]{\rightmark} % Print the nearest section name on the left side of odd pages
\fancyhead[RE]{\leftmark} % Print the current chapter name on the right side of even pages
\renewcommand{\headrulewidth}{0.5pt} % Width of the rule under the header
\addtolength{\headheight}{2.5pt} % Increase the spacing around the header slightly
\renewcommand{\footrulewidth}{0pt} % Removes the rule in the footer
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} % Style for when a plain pagestyle is specified
% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\makeatother
%%
%% Chapter headers
%%
\makeatletter
\newcommand{\thechapterimage}{}
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}
\def\thechapter{\arabic{chapter}}
\def\@makechapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};
% box decor
%\draw[fill=white,opacity=.6] (1cm,0) rectangle (8cm,-7cm);
%\node[anchor=north west] at (1cm,0) {\parbox[t][8cm][t]{6.5cm}{\huge\bfseries\flushleft \printcontents{l}{1}{\setcounter{tocdepth}{1}}}};
% title decor
\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,fill=white,fill opacity=.6,text opacity=1,draw=mainColor,draw opacity=1,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{\thechapter\ ---\ #1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\def\@makeschapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west] at (-4pt,4pt) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,fill=white,opacity=.7,inner sep=15.5pt]{\huge\sffamily\bfseries\textcolor{black}{\vphantom{plPQq}\makebox[22cm]{}}};
\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=mainColor,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{#1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\makeatother
%%
%% Section numbering format
%%
\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{mainColor}{\csname the#1\endcsname}\hspace{1em}}}
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{0.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{0.1ex}
{\normalfont\small\sffamily\bfseries}}
\makeatother
%%
%% Special environments (definition, exercise, example, furtherinfo)
%%
\RequirePackage{amsmath,amsfonts,amssymb,amsthm}
\RequirePackage[framemethod=default]{mdframed}
\makeatletter
\newtheoremstyle{mainColornum} % Theorem style name
{7pt} % Space above
{7pt} % Space below
{\normalfont} % Body font
{} % Indent amount
{\small\bf\sffamily\color{mainColor}} % Theorem head font
{\;\;} % Punctuation after theorem head
{0.25em} % Space after theorem head
{\small\sffamily\color{mainColor}\thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}} % Theorem text (e.g. Theorem 2.1)
\thmnote{\ {\the\thm@notefont\sffamily\bfseries\color{black}--- #3.}}} % Optional theorem note
\renewcommand{\qedsymbol}{$\blacksquare$} % Optional qed square
%
\newtheoremstyle{blacknum} % Theorem style name
{7pt} % Space above
{7pt} % Space below
{\normalfont} % Body font
{} % Indent amount
{\small\bf\sffamily} % Theorem head font
{\;\;} % Punctuation after theorem head
{0.25em} % Space after theorem head
{\small\sffamily\thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}} % Theorem text (e.g. Theorem 2.1)
\thmnote{\ {\the\thm@notefont\sffamily\bfseries--- #3.}}} % Optional theorem note
\renewcommand{\qedsymbol}{$\blacksquare$} % Optional qed square
\makeatother
% Defines the special environments text styles to one of the two styles above
\theoremstyle{mainColornum}
\newtheorem{definitionT}{Definition}[chapter]
\newtheorem{exerciseT}{Exercise}[chapter]
\theoremstyle{blacknum}
\newtheorem{exampleT}{Example}[chapter]
\newtheorem{furtherinfoT}{Further Information}[chapter]
% Definition box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
backgroundcolor=black!5,
linecolor=mainColor,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
innerbottommargin=5pt]{dBox}
% Exercise box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
backgroundcolor=mainColor!10,
linecolor=mainColor,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
innerbottommargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt]{eBox}
% Example box
\newmdenv[skipabove=10pt,
skipbelow=10pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=mainColor,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=0pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=0pt]{sBox}
% Further Info box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=gray,
backgroundcolor=black!5,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=5pt]{iBox}
% Creates the special environments assigning a text style and a colored box style
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
\newenvironment{exercise}{\begin{eBox}\begin{exerciseT}}{\hfill{\color{mainColor}\tiny\ensuremath{\blacksquare}}\end{exerciseT}\end{eBox}}
\newenvironment{example}{\begin{sBox}\begin{exampleT}}{\hfill{\color{mainColor}\tiny\ensuremath{\blacksquare}}\end{exampleT}\end{sBox}}
\newenvironment{furtherinfo}{\begin{iBox}\begin{furtherinfoT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{furtherinfoT}\end{iBox}}
\newenvironment{remark}{\par\vskip10pt\small % Vertical white space above the remark and smaller font size
\begin{list}{}{
\leftmargin=35pt % Indentation on the left
\rightmargin=25pt}\item\ignorespaces % Indentation on the right
\makebox[-2.5pt]{\begin{tikzpicture}[overlay]
\node[draw=mainColor!60,line width=1pt,circle,fill=mainColor!25,font=\sffamily\bfseries,inner sep=2pt,outer sep=0pt] at (-15pt,0pt){\textcolor{mainColor}{R}};\end{tikzpicture}} % Orange R in a circle
\advance\baselineskip -1pt}{\end{list}\vskip5pt} % Tighter line spacing and white space after remark
%% Make mybox
\makeatletter
\newcommand{\distas}[1]{\mathbin{\overset{#1}{\kern\z@\sim}}}%
\newsavebox{\mybox}\newsavebox{\mysim}
\newcommand{\distras}[1]{%
\savebox{\mybox}{\hbox{\kern3pt$\scriptstyle#1$\kern3pt}}%
\savebox{\mysim}{\hbox{$\sim$}}%
\mathbin{\overset{#1}{\kern\z@\resizebox{\wd\mybox}{\ht\mysim}{$\sim$}}}%
}
%% Misc
\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists
\usepackage{booktabs} % Required for nicer horizontal rules in tables
\usepackage{parskip} % Inclui \bigskip para cada linha vazia
%\usepackage{subfig} % Inclui \subfigure and \subcaptionbox environment
\usepackage{float}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
%% Copyright
\newcommand{\printcopyright}[3]{%
~\vfill
\thispagestyle{empty}
\noindent Copyright \copyright\ {#1}, {#2}\\
\noindent \textsc{This is a \LaTeX{} document template -- Designed by Daniel Marcelino (CC BY ND-3.0)}\\
\noindent \textit{First edition, {#1}}}
%%
\endinput
我正在使用 RStudio RMarkdown 输出我的文档。以下是违规案例:
---
output: pdf_document
documentclass: phdthesis
---
\newpage
## Professora Sonia Brüsch (PSDC)\index{PSDC}
\begin{figure}[ht!]
\centering
\subcaptionbox{Mapa da Votação}{
\includegraphics[width=.98\linewidth]{figures/Cabos/2016/MAPA_13.pdf}}
\makebox[0pt][r]{\raisebox{16mm}{\includegraphics[height=35mm]{figures/Cabos/2016/Legenda.pdf}}\hspace{12mm}}
\medskip
\subcaptionbox{Informações do Candidato}{
\includegraphics[width=75mm,height=30mm]{figures/Cabos/2016/13_INFO_CAND.jpg}
}\quad
\subcaptionbox{Medidas de Desempenho Eleitoral}{
\includegraphics[width=73mm,height=30mm]{figures/Cabos/2016/13_INFO_ELEIT.jpg}
}
\caption{Análise de Desempenho Eleitoral\\Professora Sonia Br$ü$sch (PSDC), Curitiba, 2016}
\end{figure}
这会产生以下不太好的合理标题:
答案1
多行标题一般都是两端对齐的,如果想让其居中,需要使用\captionsetup{justification=centering}
。
注意:某些更改纯属无端。
\documentclass{book}
\usepackage[utf8]{inputenc}
%\RequirePackage{fix-cm}
\usepackage[OT1,T1]{fontenc}
\usepackage[scaled]{helvet}
\renewcommand*\familydefault{\sfdefault}
\usepackage{microtype}
%\RequirePackage[english]{babel}
\usepackage[brazilian]{babel}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage{showframe}
\begin{document}
\begin{figure}[ht!]
\centering
\subcaptionbox{Mapa da Votação}{
\includegraphics[width=.98\linewidth]{figures/Cabos/2016/MAPA_13.pdf}}
\llap{\raisebox{16mm}{\includegraphics[height=35mm]{figures/Cabos/2016/Legenda.pdf}}\hspace{12mm}}
\medskip
\subcaptionbox{Informações do Candidato}{
\includegraphics[width=75mm,height=30mm]{figures/Cabos/2016/13_INFO_CAND.jpg}
}\quad
\subcaptionbox{Medidas de Desempenho Eleitoral}{
\includegraphics[width=73mm,height=30mm]{figures/Cabos/2016/13_INFO_ELEIT.jpg}
}
\captionsetup{justification=centering}
\caption{Análise de Desempenho Eleitoral\\Professora Sonia Br\"usch (PSDC), Curitiba, 2016}
\end{figure}
\end{document}