我试图对齐除章节编号和枚举编号之外的所有文本,使其按照相同的缩进/垂直规则对齐。基本上,章节/列表编号将全部位于一列中,而伴随它的文本将位于另一列中(尽管multicol
出于多种原因,我认为环境并不理想)。
这种对齐遵循我正在处理的文档类型的标准格式,因此格式有点奇怪。
\documentclass{report}
\usepackage{lipsum}
\usepackage[margin=1in,bottom=1.5in,top=1.25in,head=1in]{geometry}
%----Change default LaTeX section styles---------------------------
\usepackage{titlesec} % Lets user adjust section header formatting
\renewcommand\thesection{25.\arabic{section}} %Add "25." before section numbering
\setcounter{section}{-1} %Set first section number to "0"
\titleformat{\section}{\normalfont\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\bfseries}{\thesubsection}{1em}{}
%-----------------------------------------------------------------
\setlength\parindent{0pt} %no indent for all paragraphs
\begin{document}
\section[Introduction]{INTRODUCTION}
\subsection{Scope}
\lipsum[1]
\begin{enumerate}
\item This is Item 1.
\item Oh look, another item!
\item This is getting out of hand.
\end{enumerate}
\lipsum[2]
\end{document}
我的 MWE 生成如下内容:
但我正在寻找的更像是这样的:
答案1
一个简单的解决方案是使用titlesec
和enumitem
:
\documentclass{report}
\usepackage{lipsum}
\usepackage[margin=1in,bottom=1.5in,top=1.25in,head=1in, showframe]{geometry}
\setlength\parindent{0pt} %no indent for all paragraphs
\usepackage{titlesec}
%Set first section number to "0"
\titleformat{\section}{\normalfont\bfseries}{\llap{\makebox[0.6in][l]{\thesection}}}{0em}{\MakeUppercase}
\titleformat{\subsection}{\normalfont\bfseries}{\llap{\parbox{0.6in}{\thesubsection}}}{0em}{}
\usepackage{enumitem}
\setlist[enumerate]{labelwidth = \dimexpr0.6in-\labelsep, align = left, leftmargin = 0pt}
\setlist[enumerate, 2]{label=\alph*.}
\renewcommand{\rmdefault}{\sfdefault}
\begin{document}
\setcounter{chapter}{24}
\setcounter{section}{-1}
\section[Introduction]{Introduction}
\subsection{Scope}
\lipsum[1]
\begin{enumerate}
\item This is Item 1.
\item Oh look,other items!
\begin{enumerate}%[label =\alph. ]
\item A first subitem
\item Another subitem
\end{enumerate}
\item This is getting out of hand.
\end{enumerate}
Lalala
\section{Another section}
\lipsum[2]
\end{document}
答案2
\documentclass{report}
\usepackage{lipsum}
\usepackage[left=2in,right=1in,bottom=1.5in,top=1.25in,head=1in]{geometry}
\setlength\parindent{0pt} %no indent for all paragraphs
\makeatletter
\def\@seccntformat#1{\noindent\llap{\csname the#1\endcsname \quad}}
\leftmargini0pt
\begin{document}
\section[Introduction]{INTRODUCTION}
\subsection{Scope}
\lipsum[1]
\begin{enumerate}
\item This is Item 1.
\item Oh look, another item!
\item This is getting out of hand.
\end{enumerate}
\lipsum[2]
\end{document}
对于左对齐的节号:
\def\@seccntformat#1{\noindent\llap{\makebox[1in][l]{\csname the#1\endcsname}}}
或者借助enumitem
左对齐列表标签
\documentclass{report}
\usepackage{lipsum}
\usepackage[left=2in,right=1in,bottom=1.5in,top=1.25in,head=1in]{geometry}
\usepackage{enumitem}
\setlength\parindent{0pt} %no indent for all paragraphs
\makeatletter
%\def\@seccntformat#1{\noindent\llap{\csname the#1\endcsname \quad}}
\def\@seccntformat#1{\noindent\llap{\makebox[1in][l]{\csname the#1\endcsname}}}
\setlist{leftmargin=0pt,align=left,labelwidth=1in,labelsep=0pt}
\begin{document}
\section[Introduction]{INTRODUCTION}
\subsection{Scope}
\lipsum[1]
\begin{enumerate}
\item This is Item 1.
\item Oh look, another item!
\item This is getting out of hand.
\end{enumerate}
\lipsum[2]
\end{document}