编辑

编辑

以下是但是我希望文本在一列中,而不是在两列中:

在此处输入图片描述

重现行号之间的差距

\documentclass{article} % [conference]{IEEEtran}

\usepackage[mathlines]{lineno}
\usepackage{textcomp} 
\usepackage{siunitx}

\usepackage{mathtools, amssymb}
\usepackage{unicode-math} 

\linenumbers
\begin{document}

\subsection*{Electron Avalanche in GEM Foils}
There are several simplifications made in simulating the electron avalanche in GEM foils. 
There is only multiplication from electron collision. 
There is no electron lost to negative ion formation. 
The space charge effects are negligible. 
%
%
\begin{equation}
Q = n_{0} e M
\end{equation}
%
where $e$ is the electron change, and $M$ is the average \emph{gas multiplication factor} that characterizes the counter operation. 

\end{document}

给出

在此处输入图片描述

您怎样才能将这些小数字放在同一列中以供审阅?

答案1

您可以使用lineno

\documentclass[conference]{IEEEtran}
\usepackage{lipsum}
\usepackage[mathlines,switch]{lineno}


\title{The title}
\author{The authors}
\linenumbers
\begin{document}
\maketitle
\lipsum[1]
\[x=y\]
\lipsum
\end{document}

在此处输入图片描述

包选项mathlines将数字放入方程式并将switch数字放在外边缘。

对于一列,只需切换到article类。

\documentclass{article}
\usepackage{lipsum}
\usepackage[mathlines]{lineno}


\title{The title}
\author{The authors}
\linenumbers
\begin{document}
\maketitle
\lipsum[1]
\[x=y\]
\lipsum
\end{document}

在此处输入图片描述

编辑

为了回答该评论,您必须lineno在之后加载mathtools,以便方程环境的定义(由lineno包制作)不会被覆盖mathtools

\documentclass{article} % [conference]{IEEEtran}

\usepackage{textcomp}
\usepackage{siunitx}

\usepackage{mathtools, amssymb}
\usepackage[mathlines]{lineno}   %<---- here
\usepackage{unicode-math}

\linenumbers
\begin{document}

\subsection*{Electron Avalanche in GEM Foils}
There are several simplifications made in simulating the electron avalanche in GEM foils.
There is only multiplication from electron collision.
There is no electron lost to negative ion formation. 
The space charge effects are negligible.
%
%
\begin{equation}
Q = n_{0} e M
\end{equation}
%
where $e$ is the electron change, and $M$ is the average \emph{gas multiplication factor} that characterizes the counter operation.

\end{document}

在此处输入图片描述

答案2

关于以下问题的答案预览为什么当段落后跟没有空格的“对齐”方程式环境时,lineno 不会对段落进行编号?

[#1]有些线条有空隙和哈里什的回答

这两个答案都导致了不同内容中令人惊讶的差距。Harish 的答案适用于简单的数学环境,其中没有做出新的声明。前者的代码在此处重现:

\newcommand*\patchAmsMathEnvironmentForLineno[1]{%
  \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
  \renewenvironment{#1}%
     {\linenomath\csname old#1\endcsname}%
     {\csname oldend#1\endcsname\endlinenomath}}% 
\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
  \patchAmsMathEnvironmentForLineno{#1}%
  \patchAmsMathEnvironmentForLineno{#1*}}%
\AtBeginDocument{%
\patchBothAmsMathEnvironmentsForLineno{equation}%
\patchBothAmsMathEnvironmentsForLineno{align}%
\patchBothAmsMathEnvironmentsForLineno{flalign}%
\patchBothAmsMathEnvironmentsForLineno{alignat}%
\patchBothAmsMathEnvironmentsForLineno{gather}%
\patchBothAmsMathEnvironmentsForLineno{multline}%
}

它会跳过大文件中的某些行,尤其是 Math 行,例如:

在此处输入图片描述

#2将所有数字都编号,但有时会聚集在一起

\newcommand*\patchAmsMathEnvironmentForLineno[1]{%
  \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
  \renewenvironment{#1}%
     {\linenomath\csname old#1\endcsname}%
     {\csname oldend#1\endcsname\endlinenomath}}% 
\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{%
  \patchAmsMathEnvironmentForLineno{#1}%
  \patchAmsMathEnvironmentForLineno{#1*}}%
\AtBeginDocument{%
\patchBothAmsMathEnvironmentsForLineno{equation}%
\patchBothAmsMathEnvironmentsForLineno{align}%
\patchBothAmsMathEnvironmentsForLineno{flalign}%
\patchBothAmsMathEnvironmentsForLineno{alignat}%
\patchBothAmsMathEnvironmentsForLineno{gather}%
\patchBothAmsMathEnvironmentsForLineno{multline}%
}

有时给出像

在此处输入图片描述

评论

我认为姆布迪西奇的答案最适合于合作工作,就像我的情况一样,没有行不能跳过。部分编号对于评论数学来说是一个挑战。

相关内容