
次のコードがあります:
\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}
{}
{\leavevmode\leftskip 0cm\relax}
{\llap{\parbox[t]{1.5cm}{\mdseries\hfill\etocpage}\hspace{.5cm}}%
\normalsize\parbox[t]{1cm}{\quad\etocnumber\hfill}%
\parbox[t]{\dimexpr\linewidth-1cm-15pt\relax}{\etocname\par}\hfill\par
}
{}
\etocsetstyle{section}
{}
{\leavevmode\leftskip 0cm\relax}
{\llap{\parbox[t]{1.5cm}{\mdseries\hfill\etocpage}\hspace{.5cm}}%
\normalsize\parbox[t]{1cm}{\quad\etocnumber.\hfill}%
\parbox[t]{\dimexpr\linewidth-1cm-15pt\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}
\chapter{Chapter Three}
\section{Section One}
\section{Section Two}
\section{Section Three}
\end{document}
ただし、2 つの変更を加えたいと思います。
1) ページ番号と章/節番号は現在のコードでは左揃えではなく右揃えになっています。
vspace
2)目次の各章の行の少し前。
どうすればこのような結果が生まれるのでしょうか? 常に etoc コードで? ありがとう
追記 私が望む結果は次の写真のようになります:
答え1
修正
\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
}
{}
\parbox
基本的に、 es を\makebox
es with r
(右揃え)に変更し、章の2ex
3 番目の必須引数に便利な垂直スキップ (この例では ですが、必要に応じて任意の値を使用できます)を追加し\etocsetstyle
ました。
完全なコード:
\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}
結果: