Graphics, Figures & TablesColumn Alignment without Separators

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
maths-user
Posts: 6
Joined: Fri Aug 26, 2011 1:44 pm

Column Alignment without Separators

Post by maths-user »

I organized a table with mathematical equation alignment by defining := as column separator between two columns representing each one side of the equation.
My understanding is that a separator belongs to the column on the left-hand side of it. So I used \multicolumn to eliminate it, but this shifts the alignment.

If you look at the attached example: how can I align C with A and D?

Thanks for your help.

Code: Select all

documentclass{report}
\usepackage{amsmath}

\begin{document}

\begin{tabular}{@{} r@{$\text{} := \text{}$}l @{}}
A & B \\
\multicolumn{1}{r@{}}{C} & \\
D & E
\end{tabular}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Column Alignment without Separators

Post by Stefan Kottwitz »

You could use left alignment instead:

Code: Select all

\multicolumn{1}{@{}l}{C} 
However, I would not use a tabular environment, but align:

Code: Select all

\documentclass{report}
\usepackage{mathtools}
\begin{document}
\begin{align*}
A &\coloneqq B \\
C & \\
D &\coloneqq E
\end{align*}
\end{document}
Stefan
LaTeX.org admin
maths-user
Posts: 6
Joined: Fri Aug 26, 2011 1:44 pm

Column Alignment without Separators

Post by maths-user »

Thank you, Stefan.

I already thought about this and tried it out.

However, my original table is very big and complex, it would not work with the align-environment. (Only my example is so easy to describe the problem.)

Left-alignment is just not the way I want to do it. Think about the following example. I still want to have A, C and D aligned and all lines arranged around the := sign.

Thanks again for your help.

Code: Select all

\documentclass{report}

%\usepackage{amsthm} %ggf. auskommentieren
\usepackage{amsmath} %ggf. auskommentieren
%\usepackage{amssymb}

\begin{document}

\begin{tabular}{@{} r@{$\text{} := \text{}$}l @{}}
There is text. A & B \\
\multicolumn{1}{r@{}}{C} & \\
D & E \\
f(F) & G
\end{tabular}

\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Column Alignment without Separators

Post by localghost »

Probably you are looking for something like this.

Code: Select all

\documentclass[11pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}        % lädt »amsmath«

\begin{document}
  There is text. 
  \(
    \begin{aligned}[t]
      A    &\coloneqq B \\
      C    & \\
      D    &\coloneqq E \\
      f(F) &\coloneqq G
    \end{aligned}
  \)
\end{document}

Thorsten
maths-user
Posts: 6
Joined: Fri Aug 26, 2011 1:44 pm

Re: Column Alignment without Separators

Post by maths-user »

Thanks you, Thorsten for your reply. That's right, it should look like the alignment you produced. However, as already said, the mathematical "aligned"-environment is not able to be integrated in my huge table. I thought already about these mathematical equation-environments.

But maybe there is another idea to attack the problem:

How could I insert an empty textspace with the exact width of := or \colneqq ?

Is this possible with \widthof (which I tried, but do not know how to use) or some other trick?

maths-user
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Re: Column Alignment without Separators

Post by Stefan Kottwitz »

\phantom can do that, such as \phantom{$\coloneqq$} and \phantom{:=}.

Stefan
LaTeX.org admin
maths-user
Posts: 6
Joined: Fri Aug 26, 2011 1:44 pm

Re: Column Alignment without Separators

Post by maths-user »

Thanks, Stefan!

It worked. \phantom is a very useful tool. :)

maths-user
Post Reply