我正在写关于 LyX 的论文。我的目录如下:
为什么章节和子章节的页码不是在右侧对齐,而是在每个条目下方?我希望它们在右侧对齐,并且还希望有虚线。
\documentclass[12pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{setspace}
\onehalfspacing
\makeatletter
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
\date{}
\makeatother
\usepackage{babel}
\begin{document}
\tableofcontents{}
\section{\textit{Introduction}\protect \\ }
\section{\textit{Literature review}\protect \\ }
\subsection{\textit{Optimal Corporate LP}\protect \\ }
\end{document}
答案1
您在章节标题中使用了\\
-command。此命令代表“新行”,或者更准确地说是新段落。我认为您不需要这个。如果您想保留它,则必须对每个标题定义两次。一个版本用于标题,另一个版本用于目录。这看起来像\section[title for ToC]{title}
。
% arara: pdflatex
% arara: pdflatex
\documentclass[12pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc} % in most cases I would use \usepackage[utf8]{inputenc} here.
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{setspace}
\onehalfspacing
% if you want to italicize your titles, you should do it as follows:
\usepackage[explicit]{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}{1em}{\textit{#1}}
\titleformat{\subsection}
{\normalfont\large\bfseries}{\thesubsection}{1em}{\textit{#1}}
\begin{document}
\tableofcontents
\section{Introduction}
\section{Literature review}
\subsection{Optimal Corporate LP}
\end{document}