.png)
この議論を参考にすると:さらにtitlesec-etocカスタマイズ、さらに質問があります。Gonzalo Medina から提供された正常に動作するコードを検討してください。
\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{etoc}
\renewcommand{\thechapter}{\scshape\roman{chapter}}
\renewcommand\thesection{\arabic{section}}
\titleformat{\chapter}[display]
{\normalfont\fontsize{11}{12}\selectfont}
{\scshape\thechapter}
{0pt}
{}
\titleformat{\section}
{\normalfont\fontsize{11}{12}\selectfont}
{\thesection}
{1em}
{}
\titleformat{\subsection}
{\normalfont\fontsize{11}{12}\selectfont\itshape}
{}
{1em}
{}
\titlespacing{\chapter}
{0pt}{0pt}{3cm}
\etocsetstyle{chapter}
{}
{\addvspace{2ex}\leavevmode\leftskip 0cm\relax}
{\llap{\makebox[1.5cm][r]{\mdseries\etocpage}\hspace{.5cm}}%
\normalsize\makebox[1cm][r]{\etocnumber\phantom{.}}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
\etocsetstyle{section}
{}
{\leavevmode\leftskip 0cm\relax}
{\llap{\makebox[1.5cm][r]{\mdseries\etocpage}\hspace{.5cm}}%
\normalsize\makebox[1cm][r]{\etocnumber.}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
\begin{document}
\tableofcontents
\chapter{Chapter One}
\section{Section One}
\section{Section Two}
\section{Section Three}
\section{Section Four}
\chapter{Chapter Two}
\section{Section One}
\section{Section Two}
\section{Section Three}
\section{Section Four}
\section{Section Five}
\setcounter{page}{99}% just for the example
\chapter{Chapter Three}
\section{Section One}
\section{Section Two}
\section{Section Three}
\end{document}
章番号を付ける必要がない場合、各章はすべてセクション1で始まるため、元のコードを少し変更するだけで削除できます。
\etocsetstyle{chapter}
{}
{\addvspace{2ex}\leavevmode\leftskip 0cm\relax}
{\llap{\makebox[1.5cm][r]{\mdseries\phantom\etocpage}\hspace{.5cm}}%
\normalsize\makebox[1cm][r]{\etocnumber\phantom{.}}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
しかし、この方法では、星印の付いた章であるため、参考文献のページ番号 (および、索引がある場合は索引のページ番号も) が失われます。では、それらのページ番号を保持する方法はあるでしょうか? (別のケースでは を使用してこの問題を解決しましたがtitletoc/titlesec
、 を使用した現在のコードではそうではありませんetoc
)。ありがとうございます。
2018年10月 補遺
同じコードを xelates でコンパイルすると、最初のタイトル チャプターに異常な突起が生成されますが、その理由はわかりません。
\documentclass[a4paper,twoside,11pt]{report}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}
\PolyglossiaSetup{italian}{indentfirst=false}
\usepackage{titlesec}
\usepackage{etoc}
\renewcommand{\thechapter}{\scshape\roman{chapter}}
\renewcommand\thesection{\arabic{section}}
\titleformat{\chapter}[display]
{\normalfont\fontsize{11}{12}\selectfont}
{\scshape\thechapter}
{0pt}
{}
\titleformat{\section}
{\normalfont\fontsize{11}{12}\selectfont}
{\thesection}
{1em}
{}
\titleformat{\subsection}
{\normalfont\fontsize{11}{12}\selectfont\itshape}
{}
{1em}
{}
\titlespacing{\chapter}
{0pt}{0pt}{3cm}
\etocsetstyle{chapter}
{}
{\addvspace{2ex}\leavevmode\leftskip 0cm\relax}
{\ifShowPage % conditional deciding the display or not of the page number
\llap{\makebox[1.5cm][r]{\mdseries\etocpage}\hspace{.5cm}}%
\fi
\normalsize\makebox[1cm][r]{\etocnumber\phantom{.}}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
\etocsetstyle{section}
{}
{\leavevmode\leftskip 0cm\relax}
{\llap{\makebox[1.5cm][r]{\mdseries\etocpage}\hspace{.5cm}}%
\normalsize\makebox[1cm][r]{\etocnumber.}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
\newif\ifShowPage
\begin{document}
\tableofcontents
\chapter{Chapter One}
\section{Section One}
\section{Section Two}
\section{Section Three}
\section{Section Four}
\chapter{Chapter Two}
\section{Section One}
\section{Section Two}
\section{Section Three}
\end{document}
答え1
あなたの具体的な状況についてはよく分かりませんので、一般的なアドバイスしかできません。
\chapter*
したがって、ファイルには何も書き込まれないとおっしゃっています.toc
。通常、TOC のエントリを取得するには、コマンド\addcontentsline{toc}{chapter}{<Chapter title>}
の後にコマンドを使用します。\chapter*
望ましい効果を得るには、ブール値を使用する方法があります\ifShowPage
(ここでは標準のTeXのブール値を使用していますが、次のようなパッケージで提供されているブール値の方が好ましいかもしれません)。ツールボックス.) 次に、chapter
このブール値の現在の状態を調べて適切に動作するようにスタイルに指示します。
したがって、\addcontentsline{toc}{chapter}{<bibliography name>}
あなたもそうする前に
\addtocontents{toc}{\protect\ShowPagetrue}
適切に行動しますetoc
。
サンプルコード (使用するために更新し \bibname
、余分な章の追加も回避します):
\documentclass[a4paper,11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{etoc}
\renewcommand{\thechapter}{\scshape\roman{chapter}}
\renewcommand\thesection{\arabic{section}}
\titleformat{\chapter}[display]
{\normalfont\fontsize{11}{12}\selectfont}
{\scshape\thechapter}
{0pt}
{}
\titleformat{\section}
{\normalfont\fontsize{11}{12}\selectfont}
{\thesection}
{1em}
{}
\titleformat{\subsection}
{\normalfont\fontsize{11}{12}\selectfont\itshape}
{}
{1em}
{}
\titlespacing{\chapter}
{0pt}{0pt}{3cm}
\etocsetstyle{chapter}
{}
{\addvspace{2ex}\leavevmode\leftskip 0cm\relax}
{\ifShowPage % conditional deciding the display or not of the page number
\llap{\makebox[1.5cm][r]{\mdseries\etocpage}\hspace{.5cm}}%
\fi
\normalsize\makebox[1cm][r]{\etocnumber\phantom{.}}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
\etocsetstyle{section}
{}
{\leavevmode\leftskip 0cm\relax}
{\llap{\makebox[1.5cm][r]{\mdseries\etocpage}\hspace{.5cm}}%
\normalsize\makebox[1cm][r]{\etocnumber.}\hspace{10pt}%
\parbox[t]{\dimexpr\linewidth-1cm-27pt\relax}{\etocname\par}\hfill\par
}
{}
\newif\ifShowPage
\begin{document}
\tableofcontents
\chapter{Chapter One}
\section{Section One}
\section{Section Two}
\section{Section Three}
\section{Section Four}
\chapter{Chapter Two}
\section{Section One}
\section{Section Two}
\section{Section Three}
\section{Section Four}
\section{Section Five}
\setcounter{page}{99}% just for the example
\chapter{Chapter Three}
\section{Section One}
\section{Section Two}
\section{Section Three}
\cleardoublepage
\setcounter{page}{139}% just for the example
\begin{thebibliography}{99}
\addtocontents{toc}{\protect\ShowPagetrue}
\addcontentsline{toc}{chapter}{\bibname}
\bibitem{me2015} user41603, \emph{The Key to the Universe}, Cosmos Press, to appear.
\end{thebibliography}
\end{document}
更新された質問への回答(2018 年 10 月)
フォローアップの質問については、説明は簡単です。TOC は、インデントに従う段落によってタイプセットされます。TOC の最初の章のエントリは除きます。これは、文書が、セクションの見出しのindentfirst=false
後の最初の段落をインデントしないという、アングロサクソン文書の標準的な LaTeX の習慣に従うオプションを使用しているためです。ここでは、TOC の見出し「Indice」がそのように機能します。
したがって、最初の行を除くすべての行にインデント ボックスが挿入されます。
これを修正するには、多くの方法があります。例えば
\makeatletter
\etocsetstyle{chapter}
{\@afterindenttrue}
{..}
{..}
{..}
\makeatother
MWE の TOC の章とセクションのタイトルのスタイルを設定する etoc マクロでは、このような問題を回避するために\parindent
to を設定するための規定を設けることができたはずです (そうすべきだったはずです) 0pt
。また、 some を使用して幅\etociffirst{...}{...}
の空白を再挿入することもできます。\parindent