Graphics, Figures & TablesMultiline and underlining

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Multiline and underlining

Post by latexhelp1 »

I use the multiline command to stretch code across a set number of lines. The words do not necessarily span the entire set of columns but I want to denote that the columns correspond to the information in the multiline. As such, I use an underline. I would like the underline to stretch the entire duration of the columns being multilined and not just the word at hand. How would I do that?

For example, in the following code, only the words "First Group" and "Second Group" get underlined. However, I would like for both underlines to span the entire 5 columns.

Moreover, I do not want the 2 underlines to connect to each other.

For that last point, would I have to create an extra column in the table? And if so, is there a way to set that column to be of an infinitetesimal length just so the 2 underlinings don't connect?

I very much appreciate all of your help!

Code: Select all

\documentclass[12pt]{article}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage[flushleft]{threeparttable}
\usepackage[margin=1in, lmargin = 1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[font=large,labelfont=bf,tableposition=top, textfont=bf]{caption}
\usepackage{longtable}
\usepackage{array}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{mathptmx}
\usepackage[scaled]{helvet}
\usepackage{fix-cm}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\rowstyle}[1]{%
\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\begin{document}

\begin{landscape}
\begin{table}[!ht]
\caption{Table 1's Caption}\label{table1}
\centering
\begin{threeparttable}
\small
\begin{tabularx}{1.25\textwidth}{l*9{C}C}
\toprule
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) \\ 
  & A & BB & CCC & DDDD & EEEEE & FFF & GGG & HHH & III & J \\
& \multiline{5}{c}{\underline{First Group}} & \multiline{5}{c}{\underline{Second Group}}
\midrule
Variable & 0.139*** & 0.034*** & 0.032*** & 0.016*** & 0.109 &  0.053*** & -0.051 & -0.051*** & 0.011*** & -0.002*** \\
\bottomrule\addlinespace
\end{tabularx}
\begin{tablenotes}
\vspace{0.2cm}
\footnotesize{

\item \noindent \hspace{-1.8mm} Notes: 
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{landscape}

\end{document}
Last edited by latexhelp1 on Tue Nov 08, 2011 12:42 am, edited 1 time in total.

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
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Multiline and underlining

Post by localghost »

A '\multiline' command does either not exist or you forgot to load the corresponding package. Hence your example is not compilable. Fix all errors first and present a proper minimal example where all unnecessary code fragments and superfluous packages are dropped. Please keep that in mind for the future so that further reminders in this regard will be not necessary any more. *facepalm*
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Multiline and underlining

Post by latexhelp1 »

Take 2! I realize that I meant multiCOLUMN. My deepest apologies.

On another note, is it possible for the numbers to align the text such that the numbers in the rows with the *** appears directly over the numbers in the following rows with the () and also aligned with the numbers above with the (1), (2).

That is, is it possible to align the (1) with the 0.139 and the 0.002. Right now, because of the *** the second row is not aligned with regards to the number itself but rather is centered with regards to the number and the ***.

In any event, my original question is about underlining the multicolumn, in this case to underline for 4 full columns in both cases.

Thank you so much for your help.

Code: Select all


\documentclass[12pt]{article}

\usepackage[flushleft]{threeparttable}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[font=large,labelfont=bf,tableposition=top, textfont=bf]{caption}
\usepackage{longtable}
\usepackage{array}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{mathptmx}
\usepackage[scaled]{helvet}
\usepackage{fix-cm}
\usepackage{varwidth}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\rowstyle}[1]{%
\gdef\currentrowstyle{#1}%
#1\ignorespaces
}
\begin{document}

\begin{table}[!ht]
\caption{Table 1's Caption}\label{table1}
\centering
\begin{threeparttable}
\small
\begin{tabularx}{\textwidth}{l*8{C}}
\toprule
& \multicolumn{4}{c}{\underline{First Group}} & \multicolumn{4}{c}{\underline{Second Group}}\\ \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8)  \\ 
\addlinespace \midrule 
Variable & 0.139*** & 0.034*** & 0.032*** & 0.016*** & 0.109 &  0.053*** & -0.051 & -0.051***
& (0.002) & (0.003) & (0.001) & (0.004) & (0.005) & (0.006) & (0.007) & (0.008)  \\
\bottomrule\addlinespace
\end{tabularx}
\begin{tablenotes}
\vspace{0.2cm}
\footnotesize{

\item \noindent \hspace{-1.8mm} Notes: 
}
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}


Last edited by latexhelp1 on Wed Nov 02, 2011 9:43 pm, edited 1 time in total.
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Multiline and underlining

Post by latexhelp1 »

I just want to check in as to whether this is a minimum working example...

Thank you so much! :)
latexhelp1 wrote:Take 2!!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Multiline and underlining

Post by localghost »

latexhelp1 wrote:I just want to check in as to whether this is a minimum working example. […]
No, it's not. And I'm not going to explain it again. See the red links in my signature. Furthermore you are doing the same mistakes again and again that I already corrected in former threads you opened and you ignore advices given there. I don't feel like it any more.
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Multiline and underlining

Post by latexhelp1 »

Take 3? :)

I am so so so so sorry if I am not understanding the details you gave me in the other thread. I hope you realize that I do not know what you think I am apparently not following, but then the other 99% of help I have incorporated and it has helped me immensly.

You are amazing. I truly cannot thank you enough. I hope you realize how much Latex you have taught me. I am so deeply grateful for your help.
localghost wrote: No, it's not.

Code: Select all


\documentclass[12pt]{article}

\usepackage[flushleft]{threeparttable}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[font=large,labelfont=bf,tableposition=top,textfont=bf]{caption}
\usepackage{tabularx}
\usepackage{booktabs}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\rowstyle}[1]{%
\gdef\currentrowstyle{#1}%
#1\ignorespaces
}


\begin{document}

\begin{table}[!ht]
\caption{Table 1 Caption}\label{caption1}
\centering
\begin{threeparttable}
\small
\begin{tabularx}{\textwidth}{l*6{C}}
\toprule
& (1) & (2) & (3) & (4) & (5) & (6) \\ 
& \multicolumn{2}{c}{\underline{Set 1}} & \multicolumn{4}{c}{\underline{Set 2}} \\ \addlinespace
\midrule \addlinespace
Variable & -0.010 & -0.002 & -0.138* & -0.014 & 0.075 & 0.002 \\
\bottomrule\addlinespace
\end{tabularx}
\begin{tablenotes}
\vspace{0.2cm}
\footnotesize{

\item \noindent \hspace{-1.8mm} Notes: 

\noindent Sources: 
}
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}

Last edited by latexhelp1 on Sun Nov 06, 2011 8:56 pm, edited 1 time in total.
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Re: Multicolumn and underlining

Post by latexhelp1 »

Is my example still not a minimum working example? The code seems to work on my computer, I think every package I listed is essential for getting the code to work, and I don't think I did any weird coding in the table. If there is any weird coding, howeve, could we please look past it? I am just wondering about how to underline the multicolumn so that the whole multicolumn is underlined. Is this possible to do?

I so very much appreciate your help. :)
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Multiline and underlining

Post by latexhelp1 »

I really hope that the following is a minimum working example.

My question is that I would like to have the terms "Set 1" and "Set 2" be underlined such that the Set 1 underlining spans the 2 columns it is representing and Set 2 the four columns, but that these 2 underlines do not connect. Currently only the words themselves are underlined, and it is not as transparent which columns they are supposed to be in reference to.

I would so very much appreciate your help!! :D

Code: Select all

\documentclass[12pt]{article}
\usepackage[flushleft]{threeparttable}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[font=large,labelfont=bf,tableposition=top,textfont=bf]{caption}
\usepackage{tabularx}
\usepackage{booktabs}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\rowstyle}[1]{%
\gdef\currentrowstyle{#1}%
#1\ignorespaces
}

\begin{document}

\begin{table}[!ht]
\caption{Table 1 Caption}\label{caption1}
\centering
\begin{threeparttable}
\small
\begin{tabularx}{\textwidth}{l*6{C}}
\toprule
& (1) & (2) & (3) & (4) & (5) & (6) \\
& \multicolumn{2}{c}{\underline{Set 1}} & \multicolumn{4}{c}{\underline{Set 2}} \\ \addlinespace
\midrule \addlinespace
Variable & -0.010 & -0.002 & -0.138* & -0.014 & 0.075 & 0.002 \\
\bottomrule\addlinespace
\end{tabularx}
\begin{tablenotes}
\vspace{0.2cm}
\footnotesize{
\item \noindent \hspace{-1.8mm} Notes:
\noindent Sources:
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Multiline and underlining

Post by Stefan Kottwitz »

I would use \cmidrule, such as

Code: Select all

\begin{tabularx}{\textwidth}{l*6{C}}
  \toprule
  & (1) & (2) & (3) & (4) & (5) & (6) \\
  & \multicolumn{2}{c}{Set 1} & \multicolumn{4}{c}{Set 2} \\
  \cmidrule(r){2-3}\cmidrule(l){4-7}
  \addlinespace
  Variable & -0.010 & -0.002 & -0.138* & -0.014 & 0.075 & 0.002 \\
  \bottomrule\addlinespace
\end{tabularx}
Stefan
LaTeX.org admin
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Multiline and underlining

Post by latexhelp1 »

Dear Stefan,

Your code works so beautiful. You are such an intelligent, hard-working, and kind moderator. I truly do not know how to thank you enough.

You are infinitely patient with latex novices like myself. You are a true saint. Words cannot express how kind and helpful you are.
Stefan_K wrote:I would use \cmidrule, such as

Code: Select all

\begin{tabularx}{\textwidth}{l*6{C}}
  \toprule
  & (1) & (2) & (3) & (4) & (5) & (6) \\
  & \multicolumn{2}{c}{Set 1} & \multicolumn{4}{c}{Set 2} \\
  \cmidrule(r){2-3}\cmidrule(l){4-7}
  \addlinespace
  Variable & -0.010 & -0.002 & -0.138* & -0.014 & 0.075 & 0.002 \\
  \bottomrule\addlinespace
\end{tabularx}
Stefan
Post Reply