Graphics, Figures & TablesAlign Equal Signs in Table Column

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Align Equal Signs in Table Column

Post by NELLLY »

Good morning,

I have the following table, after execution the signs "=" in the first column of the table are not aligned, what could I do to make them so?

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs,multirow}
\begin{document}
\setlength{\tabcolsep}{0.8cm}
\begin{table}[bth]
\caption{Level planning of the input parameters} \centering
\begin{tabular}{ccc}\toprule[1.2pt]
\multirow{2}{*}{ Model parameter}
&\multicolumn{2}{c}{Level}\\\cmidrule{2-3}
&Low&High\\\midrule[1.2pt]
$A=p_0$&0.03&0.08 \\
$B=\delta$&0.5&1\\
$C=L_0$&50&250\\
$D=L_1$&500&700\\
$E=\lambda$&0.001&0.008\\
$F=M$&80&160\\
$G=b$&0&1\\
$H=c$&0.1&0.5\\
 \bottomrule[1.2pt]
\label{Factorlevels}
\end{tabular}
\end{table}
\end{document}

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

Align Equal Signs in Table Column

Post by tom »

Hi,

Right now, you center-align the first column. Because the content of each cell has different length, the equations are miss-aligned. You could left-align the first column which doesn't fix the problem entirely, due to the differences in letter width.

Code: Select all

\begin{tabular}{lcc}\toprule[1.2pt]
I suggest the use of separate columns.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs,multirow, array}
\begin{document}
\setlength{\tabcolsep}{0.8cm}
\begin{table}[bth]
\caption{Level planning of the input parameters} \centering
\begin{tabular}{r@{$\:$}lcc}\toprule[1.2pt]
\multicolumn{2}{l}{\multirow{2}{*}{Model parameter}}&\multicolumn{2}{c}{Level}\\\cmidrule{3-4}
&&Low&High\\\midrule[1.2pt]
$A$&$=p_0$&0.03&0.08 \\
$B$&$=\delta$&0.5&1\\
$C$&$=L_0$&50&250\\
$D$&$=L_1$&500&700\\
$E$&$=\lambda$&0.001&0.008\\
$F$&$=M$&80&160\\
$G$&$=b$&0&1\\
$H$&$=c$&0.1&0.5\\
 \bottomrule[1.2pt]
\label{Factorlevels}
\end{tabular}
\end{table}
\end{document}
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

Re: Align Equal Signs in Table Column

Post by NELLLY »

Many thanks. your proposed solution works perfectly.
Post Reply