对于单行,内容对齐很好,但是当它包含多行时情况就不一样了。对齐很奇怪:
那么我怎样才能使它们很好地对齐呢?
最小示例
\documentclass[10pt,letterpaper]{article}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage[bookmarksopen,bookmarksdepth=3]{hyperref}
\usepackage{titlesec}
\usepackage{xcolor}
%define new colors
\definecolor{dark-red}{rgb}{0.4,0.15,0.15}
\definecolor{dark-blue}{rgb}{0.15,0.15,0.4}
\definecolor{medium-blue}{rgb}{0,0,0.5}
%set up color for table of contents
\hypersetup{
colorlinks, linkcolor={medium-blue},
citecolor={dark-blue}, urlcolor={medium-blue}
}
\usepackage{tocloft}
%preven linebreak between subsection header and its content
\usepackage{titlesec}
\titleformat{\subsection}[runin]{\normalfont\bfseries}{\thesubsection.}{3pt}{}
\titleformat{\section}[runin]{\normalfont\bfseries}{\thesection.}{3pt}{}
\begin{document}
\setlength{\cftsecnumwidth}{8em} % Set numwidth of section
\setlength{\cftsubsecnumwidth}{12em} % Make subsection numwidth the same as section
\setlength{\cftsubsecindent}{\cftsecindent} % Make subsection indent the same as section
\tableofcontents
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}
\newpage
\phantomsection
\section*{Problem 4.}
\addcontentsline{toc}{section}
{
\numberline{Problem 4.}Let $T$ be a tree with $n > 1$ nodes. What is the maximum number of degrees one vertex $T$ can have?
What his the minimum number of degree one vertex $T$ can have? Justify both answers.
}
Something
\end{document}
答案1
在这个特定的例子中,您需要删除\addcontentsline
定义中包含的虚假空间:
\addcontentsline{toc}{section}
{% <------ Required
\numberline{Problem 4.}Let $T$ be a tree with $n > 1$ nodes. What is the maximum number of degrees one vertex $T$ can have?
What his the minimum number of degree one vertex $T$ can have? Justify both answers.
}
还请注意hyperref
抱怨:“PDF 字符串中不允许使用标记(PDFDocEncoding):在输入行 XXX 上删除‘数学移位’”。这是因为$ $
在目录条目中使用了数学内容,最终会出现在 PDF 书签中。要摆脱这种情况,hyperref
请提供条件\texorpdfstring{<tex-string>}{<pdf-string>}
。您可以按以下方式使用它:
\addcontentsline{toc}{section}
{% <------ Required
\numberline{Problem 4.}Let \texorpdfstring{$T$}{T} be a tree with
\texorpdfstring{$n>1$}{n>1} nodes. What is the maximum number of degrees
one vertex \texorpdfstring{$T$}{T} can have? What his the minimum number
of degree one vertex \texorpdfstring{$T$}{T} can have? Justify both answers.
}