我目前正在准备一篇必须按段落编号的论文。以下内容对我来说很合适,有点像:
\documentclass[12pt, twoside]{book}
\newcounter{chapcount}[chapter]
\newcounter{parnum}
\newlength{\parnumwidth}
\setlength{\parnumwidth}{4em}
\newcommand{\N}{%
\noindent\refstepcounter{chapcount}%
\makebox[0pt][r]{\makebox[\parnumwidth][l]{\textbf{\arabic{chapter}-
\arabic{chapcount}}}}%
\hspace*{\parindent}\ignorespaces}
\setlength{\parindent}{0em}
\begin{document}
\chapter{Introduction}
\N This is a numbered paragraph.
\N This is another paragraph.
\end{document}
不过,我想知道是否可以在左手边页面的左边距和右手边页面的右边距进行编号——这是教科书等相当常见的布局:
答案1
您可以使用\marginpar
内置有此功能的功能。
\documentclass[12pt, twoside]{book}
\newcounter{chapcount}[chapter]
\renewcommand\thechapcount{\thechapter.\arabic{chapcount}}
\newcommand{\N}{%
\par
\noindent\refstepcounter{chapcount}%
\marginpar[\raggedleft \textbf{\thechapcount}]{\raggedright \textbf{\thechapcount}}}
\setlength{\parindent}{0em}
\begin{document}
\chapter{Introduction}
\N This is a numbered paragraph.
\N This is another paragraph.
\clearpage
\N This is a numbered paragraph.
\N This is another paragraph.
\end{document}