如何强制 \linenumbers 忽略文本中的数字

如何强制 \linenumbers 忽略文本中的数字

我想在期刊论文的文本中将图 \ref{fig:something} 之后立即包含其中,以便它们可以显示在最靠近引用它们的文本的位置。效果很好。但是,\linenumbers 无法正确对图所在的行进行编号。它无法对图之前的行进行编号,但对图之后的空白行(Tex 创建)进行编号。有人可以帮忙解决这个问题吗?谢谢。

\documentclass[review, times,3p,sort&compress]{elsarticle} 
\usepackage{lineno}
\usepackage{graphicx} 
\usepackage{lipsum}
\usepackage{tikz}
\journal{some journal}
\title{Some title}
\author[wmg]{Author\corref{cor1}\fnref{someone}}
\ead{[email protected]}


\address[wmg]{Advanced Steel Research Centre, WMG, University of Warwick, Coventry CV4 7AL, UK}
\cortext[cor1]{Corresponding author}
\fntext[someone]{[email protected];[email protected]}
\synctex=1
\linenumbers
\begin{document}
    \begin{abstract}
        \begin{linenumbers}
            a lot of texts
        \end{linenumbers}
    \end{abstract}   
    \begin{keyword}
        kw1,kw2,kw3
    \end{keyword}
    \section{Results}
Figure~\ref{fig:om} and Figure~\ref{fig:gs} %
\begin{figure}[htbp]    
    \centering
    \begin{tikzpicture}
\draw (0,0) rectangle (\textwidth, 6cm);
\end{tikzpicture}
\caption{Some figure}
\label{fig:om}
\end{figure}%
\begin{figure}[htbp]
    \centering
        \begin{tikzpicture}
\draw (0,0) rectangle (\textwidth, 5cm);
\end{tikzpicture}
\caption{Another figure}
\label{fig:gs}
\end{figure}
\lipsum
\end{document}

在此处输入图片描述

答案1

通常情况下,图表应该放在段落之间,但也可以手动插入 来模拟\nopar。请注意,\noindent必须放在图表后面,因为它会另起一行。

\documentclass[review, times,3p,sort&compress]{elsarticle} 
\usepackage{lineno}
\usepackage{graphicx} 
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\nopar}{{\parfillskip=0pt \parskip=0pt \par}}

\journal{some journal}
\title{Some title}
\author[wmg]{Author\corref{cor1}\fnref{someone}}
\ead{[email protected]}


\address[wmg]{Advanced Steel Research Centre, WMG, University of Warwick, Coventry CV4 7AL, UK}
\cortext[cor1]{Corresponding author}
\fntext[someone]{[email protected];[email protected]}
\synctex=1
\linenumbers
\begin{document}
    \begin{abstract}
        \begin{linenumbers}
            a lot of texts
        \end{linenumbers}
    \end{abstract}   
    \begin{keyword}
        kw1,kw2,kw3
    \end{keyword}
    \section{Results}
Figure~\ref{fig:om} and Figure~\ref{fig:gs}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut,\nopar
\begin{figure}[htbp]    
    \centering
    \begin{tikzpicture}
\draw (0,0) rectangle (\textwidth, 6cm);
\end{tikzpicture}
\caption{Some figure}
\label{fig:om}
\end{figure}%
\begin{figure}[htbp]
    \centering
        \begin{tikzpicture}
\draw (0,0) rectangle (\textwidth, 5cm);
\end{tikzpicture}
\caption{Another figure}
\label{fig:gs}
\end{figure}\noindent
placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer
id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna
fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra
ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar
at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan
eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.
\lipsum[2-4]
\end{document}

相关内容