ラテックスの大胆な問題

ラテックスの大胆な問題
\documentclass[a4paper,12pt]{report}

\usepackage[Sonny]{fncychap}
\usepackage{fullpage}
\usepackage{algorithm}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage[toc, page, header]{appendix} 
\usepackage{fontspec}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{mathptmx}% Times Roman font
\usepackage[scaled=.90]{helvet}% Helvetica, served as a model for arial
\usepackage{xcolor}
\usepackage{titlesec}

\titleformat{\chapter}
  {\normalfont\fontsize{16}{19}\sffamily\bfseries}
  {\thechapter}
  {1em}
  {}

\titleformat{\section}
  {\normalfont\fontsize{12}{17}\sffamily\bfseries}
  {\thesection}
  {1em}
  {}

\titleformat{\subsection}
  {\normalfont\fontsize{12}{17}\sffamily\bfseries\slshape}
  {\thesubsection}
  {1em}
  {}
\setmainfont{Times New Roman}
\bibliographystyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\pagenumbering{roman}



\begin{document}
\newcounter{rom}


\input{tex/title}\newpage\thispagestyle{plain}

\addtocounter{rom}{1}\setcounter{page}{2}\newpage\thispagestyle{plain}\setcounter{page}{3}

\tableofcontents

\newpage\thispagestyle{plain}\clearpage\pagenumbering{arabic}

\input{tex/abstract}\newpage\cleardoublepage
\input{tex/acknowledgement}\newpage\cleardoublepage
\input{tex/introduction}\newpage\cleardoublepage
\input{tex/litrev}\newpage\cleardoublepage
\input{tex/conclusion}\newpage\cleardoublepage

\listoffigures
\listoftables

\bibliography{bib/Literature Review}\newpage\cleardoublepage

\end{document}

これは私が LaTeX で使用しているコードです。しかし、PDF 出力では、章の見出しやセクション、サブセクションの見出しが太字になりません。問題は何でしょうか? {\bfseries} を使用している場合でも、これらの見出しを太字にするにはどうすればよいでしょうか?

答え1

パッケージfontencとを混在させないでくださいfontspec。どちらか一方だけを使用してください。xelatexまたはを実行している場合lualatexは を使用しますfontspec。 を実行している場合pdflatexは を使用しますfontenc。 以下は の動作例ですxelatex/lualatex

\documentclass[a4paper,12pt]{report}
\usepackage[scaled=.90]{helvet}% Helvetica, served as a model for arial
\usepackage{fontspec}
\setmainfont{Times New Roman}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\chapter}
{\normalfont\fontsize{16}{19}\sffamily\bfseries}
{\thechapter}
{1em}
{}
\titleformat{\section}
{\normalfont\fontsize{12}{17}\sffamily\bfseries}
{\thesection}
{1em}
{}
\titleformat{\subsection}
{\normalfont\fontsize{12}{17}\sffamily\bfseries\slshape}
{\thesubsection}
{1em}
{}

\begin{document}
\section{A section title}   
foo bar baz

\end{document}

documentclass を使用するscrreprtと、ヘッダーはデフォルトで太字とサンセリフになります。すべての見出しを再定義する必要はありません。

関連情報