LoginSignup
1
1

More than 3 years have passed since last update.

lineno.styで一部の行に行番号がつかない

Posted at

LaTeXで行番号を振るときにはlieno.styが使われます。一部の行に番号が振られないことがあります。ググると解法がすぐに見つかります。確かに行番号がないと査読者をイラつかせるかも。式番号のない式や、番号のないスライドもしかり。

原因や解法の出所を調べたところ、lineno.styの古いバージョンを想定していると思われる記述がありました。

なんで行番号が付かないの

テキストの後に段落を分けずに別行立ての数式があると行番号が振られないことがあります。別行立ての数式があるために段落が続いているのに、改行されているためとのことです。lineno.styにはlinenomath環境があり、equationequation*環境を再定義しているため、amsmathを使わない場合、問題は発生しません。

amsmathを使う場合は、align環境などで問題が発生します。後述の通りequation環境で発生する場合もあります。

解決法

手動

lineno.stylinenomath環境で数式を囲みます。

\documentclass{article}

\usepackage{amsmath}
\usepackage{lineno}
\usepackage{lipsum}

\linenumbers

\begin{document}

\lipsum[1]
\begin{linenomath}
  \begin{align}
    a & = 6.371\times 10^{6}\,\mathrm{m} \\
    \Omega &= 7.292\times 10^{-5}\,\mathrm{s}^{-1}
  \end{align}
\end{lienomath}

\end{document}

linenomath.png

aligned

align環境ではなくequation環境の中でalignedを使うという方法もあります。ただしこの場合式番号は全体に一つだけつきます。また、amsmathでもequationが再定義されているので、amsmathlinenoよりも前に書く必要があります。

\lipsum[1]
\begin{equation}
  \begin{aligned}
    a & = 6.371\times 10^{6}\,\mathrm{m} \\
    \Omega &= 7.292\times 10^{-5}\,\mathrm{s}^{-1}
  \end{aligned}
\end{equation}

equation-aligned.png

amsmathにパッチ

冒頭のブログに掲載されていたもののオリジナルは こちらのようです。改訂版はネットニュースでやり取りする中で提案されたものですが、若い人はusenet知らないだろうな。

etoolboxを使う方法がきれいです。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1