Math & Science ⇒ Equations on two columns
Equations on two columns
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.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Equations on two columns
mathclap
command :Code: Select all
\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}
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: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Equations on two columns
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.
Equations on two columns
In what way does it fail ?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.
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: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Equations on two columns
Code: Select all
\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}
Equations on two columns
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 ?) :
Code: Select all
\newcommand{\dbleq}[3]{\begin{align}&\mathclap{#1}&&\mathclap{#2}{#3}\end{align}}
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Equations on two columns
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.
Code: Select all
\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}
Equations on two columns
I tried with the label inside the second argument, and got an error.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.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Equations on two columns
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.
Equations on two columns
Code: Select all
\newcommand{\dbleq}[3][]{\begin{align}&\mathclap{#2}&&\mathclap{#3}\label{#1}\end{align}}
The spacement could be adjusted easily :
Code: Select all
\newcommand{\dbleq}[3][]{\begin{align}&\mathclap{#2}\quad&&\quad\mathclap{#3}\label{#1}\end{align}}