4

I have looked at all related questions and not able to find solution. I have to use aligned and since aligned does not support tag, how would one add an explicit equation number?

Here is MWE

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{adjustbox}

\begin{document}
\begin{equation*} 
\adjustbox{max width=\textwidth}{%
$
\begin{aligned}
x &= y \sin(x)  \\
  &= \cos(x)    %How to number this line? \tag{3} does not work
\end{aligned}
$}
\end{equation*}
\end{document}

I do not want an automatic equation number on the equation itself. But I want to add a specific equation number on one of the equations inside aligned itself.

I tried to do it by hand, but I do not know the amount of hspace to add to make the equation number show up at the right edge of the page as what happens automatically when using tag

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{adjustbox}

\begin{document}    
\begin{equation*} 
\adjustbox{max width=\textwidth}{%
$
\begin{aligned}
x &= y \sin(x)  \\
  &= \cos(x)   \hspace*{20pt} \text{(3)}  %how to know how much space?
\end{aligned}
$}
\end{equation*}
\end{document}

Thanks for any suggestions how to do the above.

6
  • lines inside aligned cannot be numbered. Numbered can be environment in whole, i.e. equation. However, use of align which enable desired numbering of equation, doesn't work with \adjustbox.
    – Zarko
    Commented Aug 31, 2019 at 5:17
  • @Zarko Yes, I know all of this. That is why I asked. I have to use adjustbox. That is why I had to use aligned. But I also want to add an equation number. Do you know how to use hspace to add correct amount of space to end of \textwidth? If so I can do it by hand as above., But do not know how much space to add to do it manually.
    – Nasser
    Commented Aug 31, 2019 at 5:19
  • 1
    The simplest solution is not to use \adjustbox. It is (i) typographically very fragile (ii) you have only problems with hackering of its contents, by which you like to restore basic features of align environment.
    – Zarko
    Commented Aug 31, 2019 at 5:32
  • @Zarko Ok, thanks for suggestion. But I have to use adjusbox for other reasons. I'll wait a little more and if there is no solution, will delete this question in this case. No problem.
    – Nasser
    Commented Aug 31, 2019 at 5:38
  • 1
    scaling the equations is horrible, but if you must, you can/should still use align not aligned just put it in a \parbox to get back to vertical mode Commented Aug 31, 2019 at 8:33

1 Answer 1

5

Too big for a comment ...

Forcing tag to text border nullifies the effect of \adjustbox. For example, compare the following examples:

enter image description here

Both give the very same result.

\documentclass[12pt]{article}
\usepackage{amsmath,tabularx,adjustbox}
%% Automatic math-mode versions of l, r, and c column types:
\newcolumntype{L}{>{$\displaystyle}l<{$}}  
\newcolumntype{R}{>{$\displaystyle}r<{$}}
\newcolumntype{C}{>{$\displaystyle{}}c<{{}$}}

\begin{document}
\[
\setlength\tabcolsep{0pt} % <-- important
\adjustbox{max width=\textwidth}{%
  \begin{tabularx}{\linewidth}{X RCL >{\raggedleft\arraybackslash}X}
      & x & = & y \sin(x)  &     \\
      &   & = &   \cos(x)  & (3)  
  \end{tabularx}% <-- this comment symbol is needed
  }
\]

\begin{align}
    x & = y \sin(x) \notag  \\
      & =   \cos(x) \tag{3}
\end{align}    
\end{document}
3
  • Thanks, this is useful.
    – Nasser
    Commented Aug 31, 2019 at 5:51
  • 1
    +1. I've taken the liberty of editing your code so that the = symbols line up vertically in the tabularx-based example. Feel free to revert.
    – Mico
    Commented Aug 31, 2019 at 7:42
  • @Mico, thank you. In rush I wasn't careful enough :-(
    – Zarko
    Commented Aug 31, 2019 at 8:37

You must log in to answer this question.

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