0

I would like to include figures in the text in a journal paper immediately after Figure \ref{fig:something} so that they can be shown nearest to the texts referring to them. It works well. However, the \linenumbers cannot number the lines the figure are in correctly. It fails to number the line immediately before the figure but number the blank line (Tex created) immediately after the figure. Can anyone help work around this. Thank you.

\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{author1@gmail.com}


\address[wmg]{Advanced Steel Research Centre, WMG, University of Warwick, Coventry CV4 7AL, UK}
\cortext[cor1]{Corresponding author}
\fntext[someone]{someone@gmail.com;someone@warwick.ac.uk}
\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}

enter image description here

1

Normally figures are supposed to go between paragraphs, but one can fake it by hand inserting a \nopar. Note that the \noindent has to go after the figure, as it starts a new line.

\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{author1@gmail.com}


\address[wmg]{Advanced Steel Research Centre, WMG, University of Warwick, Coventry CV4 7AL, UK}
\cortext[cor1]{Corresponding author}
\fntext[someone]{someone@gmail.com;someone@warwick.ac.uk}
\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}
| improve this answer | |
  • Thank you, John. However, this does not seem to solve the problem. I do not know where to insert \nopar as this linebreaking points are determined by Tex. – Jun Nov 2 '18 at 11:31
  • You run it without \nopar, find where the line breaks, then insert \nopar in the right spot. You can use -\strut if there is hyphenation. You are attempting to do something not normally allowed, so it may take a little effort. – John Kormylo Nov 2 '18 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.