Graphics, Figures & Tablesmultirow problem

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
rajini
Posts: 64
Joined: Mon Mar 22, 2010 2:27 pm

multirow problem

Post by rajini »

Hello all,
please look at the following codes:

Code: Select all

\begin{table}[h]
\begin{minipage}[h]{\textwidth}
\renewcommand{\thefootnote}{\thempfootnote}
\caption{Assignments and summary.}\label{tab:moo1}
\vspace{3mm}
\centering
\begin{tabular}[width=1\linewidth]{lccccl}
\hline\hline
Experimental & FC      & $e_j$ &   Calculated & FP      & Mode \\[0ex]
\hline
25, 53,\\127.5\footnote{Populated with soft/modes.} & -- & -- & -- & -- &phonons\\ 
19        & 6      & 0.1    & 21        & 26      & symmetric\\ 
22        & 5      & 0.9    & 24        & 42      & asymmetric\\
27        & 7      & 0.0    & --        & -       & --\\
30        & 1      & 0.1    & 32        & 61      & symmetric\\
36        & 1      & 0.7    & 38        & 14      & described\\
39        & 1      & 0.1    & 39        & 24      & asymmet\\ 
\hline
\multirow{2}{*}{43} & \multirow{2}{*}{6}& \multirow{2}{*}{0.0}& 43 & 4 &\\ 
& &                                                          & 43 & 41 &\\
\hline\hline
\end{tabular}
\renewcommand{\footnoterule}{}
\end{minipage}
\end{table}
In the above code i want to to use multicolumn or multirow..for the 1st row-> So that 25 and 53 will be in one row and 127.5 will be in 2nd row and both these row will have a common row, which contains -- -- -- and phonon.
Can any one help out.
thanks

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

multirow problem

Post by gmedina »

Hi,

the description of your request seems incomplete (al last for me); which alignment should the mentioned data have? I mean, for example, you say
rajini wrote:...So that 25 and 53 will be in one row and 127.5 will be in 2nd row
but those conditions are already present in your table; obviously you want to make some adjustments but they are not clear to me. Should 25 and 53 belong to a specific column? Should they be centered in one row that spans the total table width?

I find the following section rather obscure (perhaps I don't understand it since English is not my native language):
rajini wrote:...and both these row will have a common row, which contains -- -- -- and phonon...
Please explain in more detail your intent.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multirow problem

Post by localghost »

Please get used to providing full examples. If I understand you right, the code below should do what you want. For further information see the manuals of the involved packages.

Code: Select all

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

\begin{document}
  \begin{table}[!ht]
    \caption{Assignments and summary}\label{tab:moo1}
    \centering
    \begin{threeparttable}
      \begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}ccccl}\toprule
        Experimental & FC & $e_j$ & Calculated & FP & Mode \\ \midrule
        25, 53, & \multirow{2}{*}{---} & \multirow{2}{*}{---} & \multirow{2}{*}{---} & \multirow{2}{*}{---} & \multirow{2}{*}{phonons} \\
        127.5\tnote{1} & & & & & \\
        19 & 6 & 0.1 & 21 & 26 & symmetric \\
        22 & 5 & 0.9 & 24 & 42 & asymmetric \\
        27 & 7 & 0.0 & --- & --- & --- \\
        30 & 1 & 0.1 & 32 & 61 & symmetric \\
        36 & 1 & 0.7 & 38 & 14 & described \\
        39 & 1 & 0.1 & 39 & 24 & asymmet \\ \midrule
        \multirow{2}{*}{43} & \multirow{2}{*}{6}& \multirow{2}{*}{0.0}& 43 & 4 & \\
        & & & 43 & 41 & \\ \bottomrule
      \end{tabular*}
      \begin{tablenotes}
        \footnotesize
        \item[1] Populated with soft/modes
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
\end{document}

Thorsten
rajini
Posts: 64
Joined: Mon Mar 22, 2010 2:27 pm

Re: multirow problem

Post by rajini »

Hello gmedina and localghost,
If you compile my codes you will get a table (see that attached file please). Now i want to draw a line after 127.5. This i can do using \hline.
What i want it..
If you see the table 1st row contains 25, 53,
and
second row contains 127.5 - - - - phonons
But i want is to group 25,53, and 127.5 as a single row. That means 25,53, and 127.5 will share the common data - - - - phonons. But if you see the attached file, - - - - belong only to 2nd row and 1st row is empty.
I can make by just typing all in one line like this: 25, 53 and 127.5. But here my table crosses the margin so i typed 25, 53 in one row and 127.5 in another row.
I am sorry, my native is not English so find somewhat difficult to express my problem. (i think i should use \multirow but how?)
thanks
Attachments
tab2.jpg
tab2.jpg (17.1 KiB) Viewed 5989 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multirow problem

Post by localghost »

rajini wrote:[...] If you compile my codes you will get a table (see that attached file please). Now i want to draw a line after 127.5. This i can do using \hline.
What i want it..
If you see the table 1st row contains 25, 53,
and
second row contains 127.5 - - - - phonons
But i want is to group 25,53, and 127.5 as a single row. That means 25,53, and 127.5 will share the common data - - - - phonons. But if you see the attached file, - - - - belong only to 2nd row and 1st row is empty. [...]
Obviously you didn't test my example. Otherwise you would have seen that you obtain exactly the desired result. The additional line you mentioned is also no problem (see code below).
rajini wrote:[...] I can make by just typing all in one line like this: 25, 53 and 127.5. But here my table crosses the margin so i typed 25, 53 in one row and 127.5 in another row. [...]
This can't be because the width of »25, 53, 127.5« is smaller than that of »Experimental« (see code below). I can stretch the table even more to fit the line width. But since you didn't provide a full example as requested with your document setup, help is not possible at this point.
rajini wrote:[...] I am sorry, my native is not English so find somewhat difficult to express my problem. (i think i should use \multirow but how?)
As you can see from our location, the mother tongue of gmedina and me is neither English. So there seems to be a language barrier on your side.

Code: Select all

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

\begin{document}
  \begin{table}[!ht]
    \caption{Assignments and summary}\label{tab:moo1}
    \centering
    \begin{threeparttable}
      \begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}ccccl}\toprule
        Experimental & FC & $e_j$ & Calculated & FP & Mode \\ \midrule
        25, 53, 127.5\tnote{1} & --- & --- & --- & --- & phonons \\ \midrule
        19 & 6 & 0.1 & 21 & 26 & symmetric \\
        22 & 5 & 0.9 & 24 & 42 & asymmetric \\
        27 & 7 & 0.0 & --- & --- & --- \\
        30 & 1 & 0.1 & 32 & 61 & symmetric \\
        36 & 1 & 0.7 & 38 & 14 & described \\
        39 & 1 & 0.1 & 39 & 24 & asymmet \\ \midrule
        \multirow{2}{*}{43} & \multirow{2}{*}{6}& \multirow{2}{*}{0.0}& 43 & 4 & \\
        & & & 43 & 41 & \\ \bottomrule
      \end{tabular*}
      \begin{tablenotes}
        \footnotesize
        \item[1] Populated with soft/modes
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
\end{document}
rajini
Posts: 64
Joined: Mon Mar 22, 2010 2:27 pm

Re: multirow problem

Post by rajini »

hello Thorsten,
I understand. It works..But all my tables in my dissertation were done without using booktabs. Just for consistency i am stick to the same order for the current table that i posted in this thread. Also i mentioned that for some reason i cant place those 3 values in a single line. Reason is..in the 'Mode' column i have to write some more text..so it crosses the page margin. But in the sample table i posted...i shortened most of the thing..(Actually i got advice from gmedina..he recommends me to remove most of the data---so that table looks simpler for you guys to help me.)

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

multirow problem

Post by localghost »

rajini wrote:[…] Also i mentioned that for some reason i cant place those 3 values in a single line. Reason is..in the 'Mode' column i have to write some more text..so it crosses the page margin. But in the sample table i posted...i shortened most of the thing. […]
That is absolutely clear to me. And so I provided an example solution with regard on that. As gmedina already assumed your problem description seems incomplete. Problems should be described by presenting a minimal example as requested earlier [1,2]. Unfortunately you denied us such an example although it has been requested. And you still do (which is quite impolite). Your problem could already have been solved.
rajini wrote:[…] (Actually i got advice from gmedina..he recommends me to remove most of the data---so that table looks simpler for you guys to help me.)[…]
I can't see this advice within this thread here. And you should not remove relevant parts from the code of your example that probably cause the problem. There are several other column types possible in the tabular environment for the case that line breaks are necessary. You could choose one for the last column. The features of this environment are extended by the array package. Furthermore you could decrease the font size with appropriate switches.

Below you find a solution with the look of your original code that works like desired. If there shall be other modification, please give a precise description by means of a minimal example. Otherwise this discussion will come to nothing.

Code: Select all

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

\begin{document}
  \begin{table}[!ht]
    \caption{Assignments and summary}\label{tab:moo1}
    \centering
    \begin{threeparttable}
      \begin{tabular}{lccccl}\hline\hline
        Experimental & FC & $e_j$ & Calculated & FP & Mode \\ \hline
        25, 53, & \multirow{2}{*}{---} & \multirow{2}{*}{---} & \multirow{2}{*}{---} & \multirow{2}{*}{---} & \multirow{2}{*}{phonons} \\
        127.5\tnote{a} & & & & & \\ \hline
        19 & 6 & 0.1 & 21 & 26 & symmetric \\
        22 & 5 & 0.9 & 24 & 42 & asymmetric \\
        27 & 7 & 0.0 & --- & --- & --- \\
        30 & 1 & 0.1 & 32 & 61 & symmetric \\
        36 & 1 & 0.7 & 38 & 14 & described \\
        39 & 1 & 0.1 & 39 & 24 & asymmetric \\ \hline
        \multirow{2}{*}{43} & \multirow{2}{*}{6}& \multirow{2}{*}{0.0}& 43 & 4 & \\
        & & & 43 & 41 & \\ \hline
      \end{tabular}
      \begin{tablenotes}
        \footnotesize
        \item[a] Populated with soft/modes
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
\end{document}
In case the problem still isn't solved, we expect a complete example with precise descriptions that shows your document setup while reduced to minimal content within your next post. Finally the suggestion to use abbreviations for »Experimental« and »Calculated« if possible.

[1] View topic: Board Rules - Everybody, my all means, read before posting!
[2] View topic: Avoidable mistakes
rajini
Posts: 64
Joined: Mon Mar 22, 2010 2:27 pm

Re: multirow problem

Post by rajini »

Hello localghost,

your last post is completely helpful. My problem is solved. I actually contacted (private via this forum) some days ago for a different help on a different table. I actually send him my complete data (i dont want to post my complete data here). So he advised me to make a shortened version of it. So i posted a minimal version in this thread. Thanks for your effort for helping me.

Rajini.
Post Reply