Graphics, Figures & TablesControlling column width in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ralarsen
Posts: 2
Joined: Tue Jan 19, 2010 11:29 am

Controlling column width in table

Post by ralarsen »

Hi
I cannot control the width of my columns. Can you help?

Code: Select all

\begin{table}
	\centering
		\begin{tabular}{|l||r|r||r|r|}\hline
		                                  & \multicolumn{2}{|c||}{THD [\%]}  & \multicolumn{2}{|c|}{DC offset [mm]}          \\\hline
                                      & \multicolumn{1}{|c|}{$\frac{1}{2}\cdot f_S$} & \multicolumn{1}{|c||}{$2\cdot f_S$} & \multicolumn{1}{|c|}{$\frac{1}{2}\cdot f_S$} & \multicolumn{1}{|c|}{$2\cdot f_S$} \\\hline
      $L_e$ asymmetric                & 0.4             & 0.5           & 0    & 0   \\\hline
      $C_{MS}$ symmetric              & 45.4            & 0.4           & 0    & 0   \\\hline
      $C_{MS}$ asymmetric             & 60.4            & 2.5           & 2.6  & 0.7 \\\hline
      $Bl$ symmetric                  & 31.3            & 2.8           & 0    & 0   \\\hline
      $Bl$ asymmetric                 & 59.9            & 17.7          & -1.4 & 2.5 \\\hline
      $Bl$ \& $C_{MS}$ asymmetric     & 72.0            & 22.9          & 0.6  & 5.2 \\\hline
		\end{tabular}
		\caption{Simulation results (THD and DC offset) from model using ode45(). These values also came out when using the Forward Euler solution}\label{table:labD_sim_results}
\end{table}
I would like the "THD" column and the "DC offset" coloumn to be evenly wide.
Attachments
Pages from template.pdf
(156.95 KiB) Downloaded 210 times

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Controlling column width in table

Post by localghost »

Perhaps you should think about reorganizing and tweaking the table.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
  \begin{table}[!ht]
    \caption{Simulation results (THD and DC offset) from model using ode45(). These values also came out when using the Forward Euler solution}\label{table:labD_sim_results}
    \centering
    \begin{tabular}{%
      l
      l
      S[tabnumalign=centre,tabformat=2.1]
      S[tabnumalign=centre,tabformat=2.1]
      @{\qquad}
      S[tabnumalign=centre,tabformat=+1.1]
      S[tabnumalign=centre,tabformat=1.1]
    }\toprule
      & & \multicolumn{2}{c}{THD}  & \multicolumn{2}{c}{DC offset} \\
      & & \multicolumn{2}{c}{[\%]} & \multicolumn{2}{c}{[mm]} \\ \midrule
      & & {$\frac{1}{2}\cdot f_S$} & {$2\cdot f_S$} & {$\frac{1}{2}\cdot f_S$} & {$2\cdot f_S$} \\ \midrule[0.8pt]
      $L_e$            & asymmetric & 0.4  & 0.5  & 0    & 0   \\
      $C_{MS}$         & symmetric  & 45.4 & 0.4  & 0    & 0   \\
      $C_{MS}$         & asymmetric & 60.4 & 2.5  & 2.6  & 0.7 \\
      $Bl$             & symmetric  & 31.3 & 2.8  & 0    & 0   \\
      $Bl$             & asymmetric & 59.9 & 17.7 & -1.4 & 2.5 \\
      $Bl$ \& $C_{MS}$ & asymmetric & 72   & 22.9 & 0.6  & 5.2 \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}

Best regards and welcome to the board
Thorsten
ralarsen
Posts: 2
Joined: Tue Jan 19, 2010 11:29 am

Re: Controlling column width in table

Post by ralarsen »

Thank you very much. Now my table looks much better :)
I would never have done this my self.
Have a nice day!
Post Reply