9

I am trying to create this kind of enumeration for the various equations of my book, similar, as this image:

enter image description here

My MWE is:

\documentclass{book}
\usepackage{mathtools}
\usepackage{newtxtext}
\usepackage{newtxmath}
\PassOptionsToPackage{svgnames, dvipsnames, table, x11names}{xcolor}
\usepackage{tikz}
\usepackage{classico}
\usepackage{pifont}
\definecolor{ocre}{RGB}{243,102,25} 
%----------------------------------------------------------------------------------
%   Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}
\renewcommand{\theequation}{\bfseries{\sffamily{\thesection-\arabic{equation}}}\textcolor{ocre}{\ding{228}}}
\begin{document}
\begin{equation}
\oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, dv 
\end{equation}
\begin{equation}
\oint \mathbf{B} \cdot d \mathbf{a} =  \mathbf{0} 
\end{equation}
\end{document}

with this output:

enter image description here

I have encountered the following problems (see the image below):

enter image description here

  1. I don't know how to eliminate the round brackets;
  2. if we suppose we don't delete the round brackets, the one on the left is not in bold while the one on the right is in bold.
  3. Using the pifont package I was trying to reverse the direction of the arrow to the left using \rotatebox{...}{...}, with the graphicx package, but I am not, probably, to rotate the direction of the arrow to the left.
  • 1
    What should a \ref (or \eqref) for an equation look like within your text? – Werner Jul 3 at 21:31
  • @Werner You're right. I hadn't thought of that. It must appear with round brackets in bold without the symbol. Since I am not good in English and I use the translator, since sometimes my question is not understandable to everyone, can I ask you to edit my question please? Upvote your comment. – Sebastiano Jul 3 at 21:35
  • So, something like this (forget the round brackets in the reference). Are you okay with using a user-defined \eqnref (rather than \ref or \eqref)? – Werner Jul 3 at 21:40
  • @Werner For both text (\eqref) and for the equations, leave the brackets round. For the rest it's ok :-). I have understood that you will have to introduce a new macro for \eqnref to get what you can't have by default. – Sebastiano Jul 3 at 21:49
  • 1
    \newtagform{Sebastiano}{}{\reflectbox{\textcolor{ocre}{\ding{227}}}} \usetagform{Sebastiano} \renewcommand{\theequation}{\bfseries{\sffamily{\thesection-\arabic{equation}}}}? – user121799 Jul 3 at 21:50
10

The following produces what you're after:

enter image description here

\documentclass{book}

\usepackage{mathtools}
\usepackage[svgnames, dvipsnames, table, x11names]{xcolor}
\usepackage{pifont}

\definecolor{ocre}{RGB}{243,102,25} 
%----------------------------------------------------------------------------------
%   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}

See both~\eqref{eq:eqn1} and~\eqref{eq:eqn2}. Also see~\eqref{eq:eqn3}.

\begin{equation}
  \oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, \mathrm{d}v \label{eq:eqn1}
\end{equation}

\begin{equation}
  \oint \mathbf{B} \cdot d \mathbf{a} =  \mathbf{0} \label{eq:eqn2}
\end{equation}

\begin{align}
  abc \label{eq:eqn3}
\end{align}

\end{document}

It uses

  • mathtools' \newtagform to establish a new form of tag for equations and related environments.

  • A conditional to set the symbol. If inside an equation or align, the symbol is added, otherwise it's left out. This allows you to use \eqref. It's not extensively tested, but works in the example provided.


If you want to remove the bold numbering from your reference, you can use the following:

enter image description here

\documentclass{book}

\usepackage{mathtools}
\usepackage[svgnames, dvipsnames, table, x11names]{xcolor}
\usepackage{pifont}

\definecolor{ocre}{RGB}{243,102,25} 
%----------------------------------------------------------------------------------
%   Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}

\makeatletter

\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnumfmt}{%
  \ifnum\pdfstrcmp{\@currenvir}{equation}=0
    \bfseries
  \else
    \ifnum\pdfstrcmp{\@currenvir}{align}=0
      \bfseries
    \fi
  \fi}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}

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

\begin{document}

See both~\eqref{eq:eqn1} and~\eqref{eq:eqn2}. Also see~\eqref{eq:eqn3}.

\begin{equation}
  \oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, \mathrm{d}v \label{eq:eqn1}
\end{equation}

\begin{equation}
  \oint \mathbf{B} \cdot d \mathbf{a} =  \mathbf{0} \label{eq:eqn2}
\end{equation}

\begin{align}
  abc \label{eq:eqn3}
\end{align}

\end{document}
  • I've had my doubts. But if I use your code within my book the numbering starts from 1 which is the first chapter or from scratch? I think it starts from scratch and I should change from 0 to 1. Finally, I forgot that there was the command reflectbox. I wanted to ask you if you could do an additional edit to delete the bold in the text part that calls the equation. – Sebastiano Jul 3 at 22:00
  • 1
    @Sebastiano: The equation numbering is section-equation, so if you don't have a \section, it will be 0. If you do, it will be 1 or higher. Also remember that \sections are number per-chapter; in other words, reset to 0 when you issue \chapter. – Werner Jul 3 at 22:07
  • My sincere and cordial thanks for your help and for those who appreciated my question in particular. – Sebastiano Jul 3 at 22:21
10

I propose this other solution, without parentheses, based on the \newtagform command from mathtools and the adforn ornaments package, which has a left-oriented arrow tip. I took the liberty to change its colour, which suits better the black characters (quia gustum meum…). Of course, feel free to choose your own colour if you prefer it:

\documentclass{book}
\usepackage{mathtools}
\usepackage{newtxtext}
\usepackage{newtxmath}
\PassOptionsToPackage{svgnames, dvipsnames, table, x11names}{xcolor}
\usepackage{tikz}
\usepackage{classico}
\usepackage{adforn}
\definecolor{ocre}{RGB}{243,102,25}
%----------------------------------------------------------------------------------
% Change number equations with sections
%----------------------------------------------------------------------------------
\counterwithin{equation}{section}%
\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newtagform{arrowtip}[\bfseries\sffamily]{}{\,\textcolor{IndianRed3}{\Large\adforn{42}}}
\usetagform{arrowtip}

\begin{document}

\setcounter{chapter}{2}
\setcounter{section}{5}
\begin{equation}
\oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, dv
\end{equation}
\begin{equation}
\oint \mathbf{B} \cdot d \mathbf{a} = \mathbf{0}
\end{equation}

\end{document} 

enter image description here

  • This does include the entire tag, as-is, in the reference (when using \eqref). Something the OP doesn't seem interested in. – Werner Jul 3 at 23:50
  • @Werner: You're right (ahd I wouldn't be interested either), but one can play with cleveref to solve the problem. – Bernard Jul 3 at 23:53
  • @Bernard Your proposal is also interesting and I vote for it. I thank you and everyone for your cooperation. I have two different codes. I will try them both :-). Thank you for everything. My sincere greetings and compliments for the Latin language :-)- – Sebastiano Jul 4 at 5:37

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.