14

The package lineno.sty is not numbering my abstract's lines. Any suggestions? Thanks.

\documentclass[a4paper,12pt]{amsart} 

\usepackage{indentfirst}
\usepackage{hyperref}
\usepackage{showkeys}

\usepackage{lineno}

\hyphenpenalty=5000
  \tolerance=1000


\begin{document}

\linenumbers

\title{Lineno in the Abstract}
\begin{abstract}
We do this, do that, ...
\end{abstract}

\maketitle

\section{Introduction}

\end{document}
1
  • 3
    Your example is not entirely a minimal one (e.g., the packages indentfirst, hyperref and showkeys aren't needed), but it does show the problem. I'm out of votes for today, but will upvote your question tomorrow.
    – lockstep
    Commented Feb 17, 2011 at 23:42

3 Answers 3

7

Seems to be an incompatibility between lineno and the amsart class. If I change the document class in your minimal example to article, the abstract's lines are numbered.

EDIT: See this answer for an in-depth explanation.

If you really need linenumbers and the amsart class (I would rather ditch amsart), here's a quick fix: Delete the abstract environment in your example. Instead, add the following immediately after \maketitle:

\vspace{-7pt}

\begin{quote}
\footnotesize
\textsc{Abstract.} We do this, do that, ...
\end{quote}

\vspace{21pt}
5
  • Hum, but that's quite bad... Any alternative? Commented Feb 17, 2011 at 23:41
  • @Florian: Hard to say ... I have no experience with amsart and don't know what to look for in its code. After you have verified my answer, delve into the documentations of both lineno and amsart for a suggested fix. Or wait some time if someone familiar with amsart drops by.
    – lockstep
    Commented Feb 17, 2011 at 23:48
  • @lockstep: I'm a very beginner in TeX, so we better wait. Thanks anyway! Commented Feb 18, 2011 at 2:06
  • Not contrary to me at all! I was simply assuming that amsart was the sine qua non in this case. Commented Feb 18, 2011 at 12:19
  • @lockstep: no need to fix that! By the way, I've gone for a slightly deeper hack, but I think that yours is the simplest way and given that line numbering surely isn't going to be in the final version (is it?) of whatever document, then the simplest hack is probably the best. Commented Feb 18, 2011 at 13:06
11

Page 1, lines 11-12 of the lineno states:

lineno.sty can only number lines in the main text. Lines in any kind of boxes cannot be numbered. But see section 7.4 below.

The AMS class file typesets the abstract as part of the title page, but the abstract is specified using an environment. So it has to slurp in the text and save it for reuse. It does that by using a box, precisely the situation that lineno.sty warns us against.

Section 7.4 may help but it is not a true numbering: it describes an extension of lineno.sty that simply typesets a list of numbers down the left in the vague hope that they will line up correctly with the lines in the box.

So to answer your question: No, I have no suggestions! Other than to ask, do you really need your abstract to have line numbers?


Okay, I do have a suggestion.

\documentclass{amsart}

\usepackage{lipsum}
\usepackage{lineno}

\makeatletter
\let\my@abstract=\relax
\def\abstract#1{%
  \def\my@abstract{%
    \normalfont\Small
    \list{}{\labelwidth\z@
      \leftmargin3pc \rightmargin\leftmargin
      \listparindent\normalparindent \itemindent\z@
      \parsep\z@ \@plus\p@
      \let\fullwidthdisplay\relax
    }%
    \item[\hskip\labelsep\scshape\abstractname.]%
    #1
  \endlist}}
\def\@setabstracta{%
  \ifx\my@abstract\relax
  \else
    \skip@20\p@ \advance\skip@-\lastskip
    \advance\skip@-\baselineskip \vskip\skip@
  \my@abstract
    \prevdepth\z@ % because \abstractbox is a vtop
  \fi
}
\makeatother

\linenumbers
\begin{document}
\title{Line numbering and amsart}

\abstract{%
\lipsum[1]}

\maketitle

\lipsum[2]

\end{document}

I don't particularly recommend it, and it needs a little adjusting to get the spacing right above and below. Basically, it reimplements the amsart abstract handling without using a box. It's ugly, it's hacky, and it probably just sent a coded signal to the AMS which will get me on their naughty list for years to come. But it does number the lines of the abstract and, apart from the spacing, it looks right.

amsart with lineno

3
  • 2
    nah, not on the ams naughty list. the ams document classes are designed for specific purposes, and we don't promise to be compatible with all other packages. the reason the abstract is included as part of the top matter is to make it easier to segregate and pull out for use in the on-line contents list for ams journals. automated processes put tight restrictions on what is allowable. if an article were submitted with your coding, yes, we'd scream, but if it's just for your own use, what's the problem? Commented Mar 23, 2011 at 19:31
  • @barbara: Phew! I was worried there. I still have hopes of - one day! - getting an article accepted by one of the AMS journals so I'm pleased to hear that I haven't prejudiced my case. Commented Mar 23, 2011 at 20:21
  • @barbara (actually, I'm misremembering. My first published article was in an AMS series. So I've already gotten one in. I now want to show that it wasn't a fluke!) Commented Mar 23, 2011 at 21:15
7

I find a simple solution for working with lineno package and elsarticle class: just write these scripts in your code:

\begin{abstract}
\begin{linenumbers}

your abstract text...

\end{linenumbers}
\end{abstract}
1
  • 3
    The question specifically deals with the amsart document class, for which your suggested solution still doesn't solve the problem.
    – Werner
    Commented Nov 10, 2015 at 6:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .