1

Considering my previous question at this link One or more equations (two-by-two on different rows) with an enumerate to the left and the another on the right, I have a strange alignment behavior of two numbered equations on the same line. In other words there is an overhang between the (0.0-3) and (0.0-4) equations.

How can the problem be corrected?

Here there is the MWE and the relative output:

\documentclass{book}
\usepackage[top=2.5cm,bottom=2.2cm,
            left=3.2cm,right=1.5cm,headsep=10pt,
            a4paper]{geometry}  
\usepackage{mathtools,amssymb}
\usepackage[svgnames, dvipsnames, table, x11names]{xcolor}
\usepackage{pifont}
\usepackage{tabularx} 
\definecolor{ocre}{RGB}{243,102,25} 
\usepackage{lipsum} %%%%%%%%%%% <--------- added 

%----------------------------------------------------------------------------------
%   Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}

\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}

\makeatletter
\newtagform{bbrackets}% <name>
  [\textbf]% Internal style
  {(}% Left bracket
  {\ifnum\pdfstrcmp{\@currenvir}{equation}=0
     \eqnnumsymbol%
   \else
     \ifnum\pdfstrcmp{\@currenvir}{align}=0
       \eqnnumsymbol%
     \fi
   \fi
   )}% Right bracket
\makeatother
\usetagform{bbrackets}

\begin{document}
\lipsum[5][2-3]

\begin{tabularx}{\textwidth}{@{}XXX@{}}
\begin{equation}
f(x + y) = f(x) + f(y),
\label{eqn:1}
\end{equation} &
\begin{equation}
f(ax) = af(x),\,
x,y\in V, a\in\mathbb{C}
\label{eqn:2}
\end{equation}
\end{tabularx}

\lipsum[6][8-9]

\begin{tabularx}{\textwidth}{@{}XXX@{}}
\begin{equation}
\overline{E}= -\overline \nabla \varphi-\frac{\partial \overline{A}}{\partial t}
\label{eqn:3}
\end{equation} &
\begin{equation}
\overline{B}=\overline \nabla \times\overline{A}
\label{eqn:4}
\end{equation}
\end{tabularx}
\end{document}

Output:

enter image description here

5
  • unrelated note you are missing \noindent before the \begin{tabularx} (see the 15pt warnings in the log) and you declare three columns but only use two. Commented Sep 7, 2019 at 15:51
  • It is not clear what other behaviour you expect, one equation is taller than the other so it takes more vertical space, you would see the same if it was an image of a tikzpicture or anything else, not just equations. Commented Sep 7, 2019 at 15:52
  • @DavidCarlisle I'm absolutely agree with you on \noindent. Into my structure there is no this problem. After I have @{}XXX@{} used directly the code from Stefan Kottwitz's answer tex.stackexchange.com/questions/33433/…
    – Sebastiano
    Commented Sep 7, 2019 at 15:59
  • 1
    You can fake the height with vphantom: \overline{B}=\overline \nabla \times\overline{A}\vphantom{-\frac{\partial \overline{A}}{\partial t}}.
    – Marijn
    Commented Sep 7, 2019 at 16:00
  • 1
    Stefan used XXX as he had three equations per line, so three columns in the table. Commented Sep 7, 2019 at 16:02

2 Answers 2

1

I wouldn't really expect these to be aligned as they have different sizes, however you can get a bit closer if you use m rather than p columns. I use tabular here as tabularx isn't really helping as you know in advance given XX that there will be two equal columns, so you may as well specify that directly.

enter image description here

\documentclass{book}
\usepackage[top=2.5cm,bottom=2.2cm,
            left=3.2cm,right=1.5cm,headsep=10pt,
            a4paper]{geometry}  
\usepackage{mathtools,amssymb}
\usepackage[svgnames, dvipsnames, table, x11names]{xcolor}
\usepackage{pifont}
\usepackage{tabularx} 
\definecolor{ocre}{RGB}{243,102,25} 
\usepackage{lipsum} %%%%%%%%%%% <--------- added 

%----------------------------------------------------------------------------------
%   Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}

\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}

\makeatletter
\newtagform{bbrackets}% <name>
  [\textbf]% Internal style
  {(}% Left bracket
  {\ifnum\pdfstrcmp{\@currenvir}{equation}=0
     \eqnnumsymbol%
   \else
     \ifnum\pdfstrcmp{\@currenvir}{align}=0
       \eqnnumsymbol%
     \fi
   \fi
   )}% Right bracket
\makeatother
\usetagform{bbrackets}

\begin{document}
\lipsum[5][2-3]

\noindent
\begin{tabular}{@{}*{2}{m{.5\textwidth}@{}}}
\begin{equation}
f(x + y) = f(x) + f(y),
\label{eqn:1}
\end{equation} &
\begin{equation}
f(ax) = af(x),\,
x,y\in V, a\in\mathbb{C}
\label{eqn:2}
\end{equation}
\end{tabular}

\lipsum[6][8-9]

\noindent
\begin{tabular}{@{}*{2}{m{.5\textwidth}@{}}}
\begin{equation}
\overline{E}= -\overline \nabla \varphi-\frac{\partial \overline{A}}{\partial t}
\label{eqn:3}
\end{equation} &
\begin{equation}
\overline{B}=\overline \nabla \times\overline{A}
\label{eqn:4}
\end{equation}
\end{tabular}
\end{document}
1

Thank you very much to @David Carlisle and @Marijn that with your comments I have had another possibility:

enter image description here

\documentclass{book}
\usepackage[top=2.5cm,bottom=2.2cm,
            left=3.2cm,right=1.5cm,headsep=10pt,
            a4paper]{geometry}  
\usepackage{mathtools,amssymb}
\usepackage[svgnames, dvipsnames, table, x11names]{xcolor}
\usepackage{pifont}
\usepackage{tabularx} 
\definecolor{ocre}{RGB}{243,102,25} 
\usepackage{lipsum} %%%%%%%%%%% <--------- added 

%----------------------------------------------------------------------------------
%   Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}

\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}

\makeatletter
\newtagform{bbrackets}% <name>
  [\textbf]% Internal style
  {(}% Left bracket
  {\ifnum\pdfstrcmp{\@currenvir}{equation}=0
     \eqnnumsymbol%
   \else
     \ifnum\pdfstrcmp{\@currenvir}{align}=0
       \eqnnumsymbol%
     \fi
   \fi
   )}% Right bracket
\makeatother
\usetagform{bbrackets}

\begin{document}
\lipsum[5][2-3]

\begin{tabularx}{\textwidth}{@{}XX@{}}
\begin{equation}
f(x + y) = f(x) + f(y),
\label{eqn:1}
\end{equation} &
\begin{equation}
f(ax) = af(x),\,
x,y\in V, a\in\mathbb{C}
\label{eqn:2}
\end{equation}
\end{tabularx}

\lipsum[6][8-9]

\begin{tabularx}{\textwidth}{@{}XX@{}}
\begin{equation}
\overline{E}= -\overline \nabla \varphi-\frac{\partial \overline{A}}{\partial t}
\label{eqn:3}
\end{equation} &
\begin{equation}
\overline{B}=\overline \nabla \times\overline{A}\vphantom{-\frac{\partial \overline{A}}{\partial t}}
\label{eqn:4}
\end{equation}
\end{tabularx}
\end{document}

You must log in to answer this question.

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