TransWikia.com

Using dotfill in aligned multiline equation

TeX - LaTeX Asked by jiaopjie on February 9, 2021

I’m editing some file containing grading scale.
There are some aligned equations which have a tag with dotted leaders.
enter image description here

Maybe it isn’t a good idea to remain the dotted leaders.
But I wonder whether one can obtain this result.

Here is my approach.

documentclass{article}
newcommand{dif}{mathop{}!mathrm{d}}
newcommand{vare}{mathrm{e}}
begin{document}
parindent0pt
Solution:
[1em]hspace*{4cm}
$dif vare^{x+y} = vare^{x+y} dif (x+y)$
dotfill ($+1'$)
[1em]hspace*{5cm}
$= vare^{x+y} (dif x + dif y)$
dotfill ($+1'$)
end{document}

As you can see, the code is somewhat ugly.

The difficulty is to align the middle equations at the equal sign.
The align environment can satisfy this.

documentclass{article}
usepackage{amsmath}
newcommand{dif}{mathop{}!mathrm{d}}
newcommand{vare}{mathrm{e}}
begin{document}
Solution:
begin{align*}
  dif vare^{x+y} &= vare^{x+y} dif (x+y)        tag{$+1'$}
                   &= vare^{x+y} (dif x + dif y) tag{$+1'$}
end{align*}
end{document}

But I can’t produce the dotted leaders.

Question: Whether one can replace the white space between the equation and the right tag with dotted leaders?

Any comments are welcome.
Thank you very much!


Update

I try another solution, which is not ugly so much. With loading the array package, the following code seems not too ugly.

documentclass{article}
usepackage{array}
newcommand{dif}{mathop{}!mathrm{d}}
newcommand{vare}{mathrm{e}}
begin{document}
Solution:
hspace*{fill}
(
  begin{array}[t]{@{}r<{{}}@{}>{${}}p{7cm}<{$}@{}}
    dif vare^{x+y} &= vare^{x+y} dif (x+y)        dotfill (+1')
                     &= vare^{x+y} (dif x + dif y) dotfill (+1')
  end{array}
)
end{document}

As you can see, one still need to modify the width of the last column manually.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP