Can't we use centering tabs in LaTeX ?

I'm already using the tabto package, just for some very specific usages. But apparently, I can use it just to push things to the right, not to center items, and I'm not sure its working with equations.

## LaTeX forum ⇒ Math & Science ⇒ Equations on two columns Topic is solved

`mathclap`

command :

\documentclass[12pt,letterpaper]{book} \usepackage[T1]{fontenc} \usepackage{mathtools} \usepackage{showframe} \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry} \begin{document} \begin{align} &\mathclap{x = y^2 - c + d + z^3,} &&\mathclap{z = x^3 + x - y^2.} \end{align} Just another small line of text : \begin{align} &\mathclap{x -5 y + 3 = y^2,} &&\mathclap{y^2 = -\: x^2 + 4 - y^2 - x.} \end{align} Yet another line : \begin{align} &\mathclap{A + B + E = b,} &&\mathclap{B - C = 0.} \end{align} The global distribution of these equations is less ugly ! \end{document}

Here's a preview of a more complex document, using

`mathclap`

inside the `align`

environment. The equations are centered around the blue lines, approximately. Take note that the point "." and the comma "," must be included inside the `mathclap`

directive.What do you think ?

Any problem with this, that I can't see for the moment ?

And what about the spacing between the blue lines ? Can it be adjusted ?

- Johannes_B
- Site Moderator
**Posts:**4118**Joined:**Thu Nov 01, 2012 4:08 pm

http://chat.stackexchange.com/transcrip ... 2#19534572

You didn't follow the discussion that was trying to solve your your problem?

Why is there no package for that? Apparently, no one had need for it so far. I suggest to reach to the maintainers via mail and present the problem as well as the motivation for doing so. They may know more about alternatives. Don't forget to link this discussion, they might be interested in what was discussed and presented so far.

You didn't follow the discussion that was trying to solve your your problem?

`\mathclap`

puts its content in a box of zero width and centers it. Was my very first test, but it fails when an equation is very long. So once again, this is a manual thing. Why is there no package for that? Apparently, no one had need for it so far. I suggest to reach to the maintainers via mail and present the problem as well as the motivation for doing so. They may know more about alternatives. Don't forget to link this discussion, they might be interested in what was discussed and presented so far.

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Johannes_B wrote:`\mathclap`

puts its content in a box of zero width and centers it. Was my very first test, but it fails when an equation is very long. So once again, this is a manual thing.

In what way does it fail ?

I guess that a long equation could overlap on the second one, but then you may get the same with any double equations styles.

If an equation is very long, I wouldn't put it in a double equation line anyway.

Double equations aren't intended for long equations.

How could we define a new environment, using the solution I'm proposing ?

- Johannes_B
- Site Moderator
**Posts:**4118**Joined:**Thu Nov 01, 2012 4:08 pm

\documentclass[12pt,letterpaper]{book} \usepackage[T1]{fontenc} \usepackage{mathtools} \usepackage{showframe} \usepackage{tabularx} \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry} \newcommand{\dbleq}[2]{\begin{align}&\mathclap{#1}&&\mathclap{#2}\end{align}} \begin{document} \dbleq{x = y^2 - c + d + 12b + 17 c - 4f -(x^r)^2 z^3,}{y^2 = -\: x^2 + 4 - y^2 - x.} Just another small line of text : \dbleq{x -5 y + 3 = y^2,}{y^2 = -\: x^2 + 4 - y^2 - x.} \end{document}

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

It's evident that I wouldn"t present the first two equations in a double-equs line.

Like I said in my first message (on page 1), the double-equs line is used just for two small equations.

Thanks a lot for the macro. Should be usefull.

EDIT : But then, how do you add a label to a double-equs., using your macro ?

EDIT 2 : I guess we need to modify the macro like this (is that the right way to do it, for an optional label ?) :

\newcommand{\dbleq}[3]{\begin{align}&\mathclap{#1}&&\mathclap{#2}{#3}\end{align}}

I suspect that for an optional label, the command should be like \dbleq[label]{eq1}{eq1}

- Johannes_B
- Site Moderator
**Posts:**4118**Joined:**Thu Nov 01, 2012 4:08 pm

No, you don't you can just type in the label in the second argument. Look at it, it is exaclty the same that you came up with.

If you want to have an extra argument just for the label, you could also define an optional argument. With package xparse you can save even more time. And after all, LaTeX is a macro language.

DISCLAIMER: Macros for saving typing time are bad, especially when math is involved. This might break sooner than you wish.

If you want to have an extra argument just for the label, you could also define an optional argument. With package xparse you can save even more time. And after all, LaTeX is a macro language.

\documentclass[12pt,letterpaper]{book} \usepackage[T1]{fontenc} \usepackage{mathtools} \usepackage{showframe} \usepackage{tabularx} \usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry} \newcommand{\dbleq}[3][]{\begin{align}&\mathclap{#2}&&\mathclap{#3}#1\end{align}} \usepackage{xparse} \NewDocumentCommand{\dblq}{ m m o }{% \begin{align}&\mathclap{#1}&&\mathclap{#2}\IfNoValueTF{#3}{}{\label{eq:#3}}\end{align}} \begin{document} \dbleq{x = y^2 - c + d + 12b + 17 c - 4f -(x^r)^2 z^3,}{y^2 = -\: x^2 + 4 - y^2 - x.} Just another small line of text : \dbleq[\label{eq:cham}]{x -5 y + 3 = y^2,}{y^2 = -\: x^2 + 4 - y^2 - x.} can we refer to \eqref{eq:cham} and \eqref{eq:chamA}? \dblq{x -5 y + 3 = y^2,}{y^2 = -\: x^2 + 4 - y^2 - x.}[chamA] \end{document}

DISCLAIMER: Macros for saving typing time are bad, especially when math is involved. This might break sooner than you wish.

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Johannes_B wrote:No, you don't you can just type in the label in the second argument. Look at it, it is exaclty the same that you came up with.

I tried with the label inside the second argument, and got an error.

- Johannes_B
- Site Moderator
**Posts:**4118**Joined:**Thu Nov 01, 2012 4:08 pm

Ah, right, sorry. My mistake.

Mathtools typesets its argument 4 times in different styles and applies only once. Hence you get the error of defining the same label multiple times.

Mathtools typesets its argument 4 times in different styles and applies only once. Hence you get the error of defining the same label multiple times.

\newcommand{\dbleq}[3][]{\begin{align}&\mathclap{#2}&&\mathclap{#3}\label{#1}\end{align}}

This way, you don't need to type \label{}, since it's already defined as an optional argument just for the label. And the code is then easier to read and to understand (I think).

The spacement could be adjusted easily :

\newcommand{\dbleq}[3][]{\begin{align}&\mathclap{#2}\quad&&\quad\mathclap{#3}\label{#1}\end{align}}

According to the quick test I just made, this is working great, even with large equation numbers :

### Who is online

Users browsing this forum: No registered users and 3 guests