maranget / hevea

Hevea is a fast latex to html translator
http://hevea.inria.fr
Other
98 stars 12 forks source link

Aligned equation numbers #28

Closed cspiel closed 4 years ago

cspiel commented 4 years ago

This PR aligns equation numbers flush to the right (default) or the left (document option "leqno") margin similar to LaTeX.

Here is an example source file to try the change:

\documentclass[]{article}% try option: `leqno'

\usepackage{hevea}

\ifhevea
  \renewcommand{\vec}[1]{\mathbf{#1}}
\fi

\newif\ifnabla\nablafalse
\newcommand*{\grad}{\ifnabla\ensuremath{\nabla}\else\mbox{grad}\fi}
\renewcommand*{\div}{\ifnabla\ensuremath{\nabla \cdot}\else\mbox{div}\fi}
\newcommand*{\curl}{\ifnabla\ensuremath{\nabla \times}\else\mbox{curl}\fi}

%%  Comment-out to get default layout.
\newstyle{body}{margin: auto; max-width: 36em; width: 60\%}

%%  Uncomment to revert to old behavior.
%\newstyle{.equationnumber}{float: none; left: 2em; position: relative; right: auto}
%\newstyle{.equationnumber-valign}{float: none; left: auto; margin-top: auto; position: relative; right: auto}

\begin{document}
\begin{equation}
  \frac{\partial \rho}{\partial t} + \div \vec{\jmath} = 0
\end{equation}

\begin{eqnarray}
  \int_S \vec{E} \cdot d\vec{S}  &  =  &  \int_V \rho\,d\/{}^{3}\!x  \\
  \oint_C \vec{B} \cdot d\vec{x}  &  =  &  \int_S \left(\vec{\jmath} + \frac{\partial \vec{E}}{\partial t}\right) d\vec{S}  \\
  \int_S \vec{B} \cdot d\vec{S}  &  =  &  0  \\
  -\oint_C \vec{E} \cdot d\vec{x}  &  =  &  \int_S d\vec{S} \cdot \frac{\partial \vec{B}}{\partial t}
\end{eqnarray}
\end{document}

I have split the change in two patches: The first is the one I wanted to write, but it interferes with vertical alignment in a mysterious way. Therefore I "fixed" the vertically misaligned numbers in eqnarray with the second patch. @maranget, if you know of a better way please revert the last patch and substitute a cleaner solution.

maranget commented 4 years ago

I have no clear opinion on your second commit. So I keep it.. Thanks for your contribution.