Archiv verlassen und diese Seite im Standarddesign anzeigen : Master Detail Table With Tabu Linewidth Incorrect. Why?
Hi, I'm new to this forum and have a problem creating a complex table with a master detail detail use case. I created a minimal example shown the problem and would be happy if somebody has an idea why the linewidth is too wide in the multicolumn on level 2 of the master detail szenario.
Here is the example code:
\documentclass[a4paper, titlepage, oneside]{report}
%use of packages
\usepackage{tabu}
\usepackage{longtable}
\usepackage[a4paper, left=2cm, right=2cm, top=1cm, bottom=1cm, includeheadfoot]{geometry}
\setcounter{chapter}{0}
\makeatletter\@addtoreset{chapter}{part}\makeatoth er
\begin{document}
\parindent 0pt
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{longtabu} to 0.8\linewidth{ | X[-1] | X[-1,r] | X[-1] | }
\hline
\multicolumn{3}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endhead
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endfirsthead
\hline
\multicolumn{3}{|r|}{\small\sl continued on next page}\\
\hline
\endfoot
\endlastfoot
0 h & 1 & 0 h\\
\tabuphantomline
\cline{1-3}
\multicolumn{3}{|c|}{
\begin{tabu}{ | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Intravenous Bolus & \\
\tabuphantomline
\tabuphantomline
\end{tabu}
}\\
\cline{1-3}2.00 h & 5 & 10 h\\
\tabuphantomline
\cline{1-3}
\multicolumn{3}{|c|}
{\begin{tabu}{ | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Oral & Formulation\\
\tabuphantomline
\cline{1-4}
\multicolumn{4}{|c|}
{\begin{tabu}{ | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Parameter}} & \multicolumn{1}{c|}{\textbf{Value}}\\
\cline{1-2}Volume of water/body weight & 22.00 ml/kg\\
\tabuphantomline
\tabuphantomline
\end{tabu}
}\\
\cline{1-4}\tabuphantomline
\end{tabu}
}\\
\cline{1-3}\tabuphantomline
\hline
\caption{Master Detail Detail Table}
\label{b2bb297be8004446bb38ae83c7107709}
\\
\end{longtabu}
\end{center}
\end{document}
Curryhunter
14-03-2013, 12:44
Hi There,
I added some
to 0.8\linewidth because as far as I understand the package documentation you need to give the width dimension to all tables.
Is it possible that you messed up the number of columns in your tables?
\documentclass[a4paper, titlepage, oneside]{report}
%use of packages
\usepackage{tabu}
\usepackage{longtable}
\usepackage[a4paper, left=2cm, right=2cm, top=1cm, bottom=1cm, includeheadfoot]{geometry}
\setcounter{chapter}{0}
\makeatletter\@addtoreset{chapter}{part}\makeatoth er
\begin{document}
\parindent 0pt
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{longtabu}to 0.8\linewidth{ | X[-1] | X[-1,r] | X[-1] | }
\hline
\multicolumn{3}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endhead
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endfirsthead
\hline
\multicolumn{3}{|r|}{\small\sl continued on next page}\\
\hline
\endfoot
\endlastfoot
0 h & 1 & 0 h\\
\tabuphantomline
\cline{1-3}
\multicolumn{3}{|c|}{
\begin{tabu} to 0.8\linewidth { | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Intravenous Bolus & \\
\tabuphantomline
\tabuphantomline
\end{tabu}
}\\
\cline{1-3}2.00 h & 5 & 10 h\\
\tabuphantomline
\cline{1-3}
\multicolumn{3}{|c|}
{\begin{tabu} to 0.8\linewidth{ | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Oral & Formulation\\
\tabuphantomline
\cline{1-4}
\multicolumn{4}{|c|}
{\begin{tabu} to 0.8\linewidth { | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Parameter}} & \multicolumn{1}{c|}{\textbf{Value}}\\
\cline{1-2}Volume of water/body weight & 22.00 ml/kg\\
\tabuphantomline
\tabuphantomline
\end{tabu}
}\\
\cline{1-4}\tabuphantomline
\end{tabu}
}\\
\cline{1-3}\tabuphantomline
\hline
\caption{Master Detail Detail Table}
\label{b2bb297be8004446bb38ae83c7107709}
\\
\end{longtabu}
\end{center}
\end{document}
Thanks a lot for your help!
Unfortunately that does not solve the problem in full.
I had also played with the 0.8\linewidth but did not have any ratio for it.
To your question: It would be easily possible to figure out the number of actual used columns, because the complete code will be generated by a program.
If I change the c to p{\linewidth} the table is not too wide anymore.
Will that be the case for all those tables? Why does the c alignment fail?
Any information about the multicolumn, tabu, longtabu interaction would be highly welcome.
Here is the working but not very nice solution...
\documentclass[a4paper, titlepage, oneside]{report}
%use of packages
\usepackage{tabu}
\usepackage{longtable}
\usepackage[a4paper, left=2cm, right=2cm, top=1cm, bottom=1cm, includeheadfoot]{geometry}
\setcounter{chapter}{0}
\makeatletter\@addtoreset{chapter}{part}\makeatoth er
\begin{document}
\parindent 0pt
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{longtabu} to 0.8\linewidth{ | X[-1] | X[-1,r] | X[-1] | }
\hline
\multicolumn{3}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endhead
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endfirsthead
\hline
\multicolumn{3}{|r|}{\small\sl continued on next page}\\
\hline
\endfoot
\endlastfoot
0 h & 1 & 0 h\\
\cline{1-3}
\multicolumn{3}{|p{\linewidth}|}{
\begin{tabu} to 0.8\linewidth { | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Intravenous Bolus & \\
\end{tabu}
}\\
\cline{1-3}2.00 h & 5 & 10 h\\
\cline{1-3}
\multicolumn{3}{|p{\linewidth}|}
{\begin{tabu} to 0.8\linewidth { | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Oral & Formulation\\
\cline{1-4}
\multicolumn{4}{|p{0.8\linewidth}|}
{\begin{tabu} to 0.8\linewidth { | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Parameter}} & \multicolumn{1}{c|}{\textbf{Value}}\\
\cline{1-2}Volume of water/body weight & 22.00 ml/kg\\
\end{tabu}
}\\
\cline{1-4}
\end{tabu}
}\\
\cline{1-3}
\hline
\caption{Master Detail Detail Table}
\label{b2bb297be8004446bb38ae83c7107709}
\\
\end{longtabu}
\end{center}
\end{document}
\documentclass[a4paper, titlepage, oneside]{report}
%use of packages
\usepackage{tabu}
\usepackage{longtable}
\usepackage[a4paper, left=2cm, right=2cm, top=1cm, bottom=1cm, includeheadfoot]{geometry}
\setcounter{chapter}{0}
\makeatletter\@addtoreset{chapter}{part}\makeatoth er
\begin{document}
\parindent 0pt
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{longtabu} to 0.8\linewidth{ | X[-1] | X[-1,r] | X[-1] | }
\hline
\multicolumn{3}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endhead
\hline
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Number of Repetitions}} & \multicolumn{1}{c|}{\textbf{Time Between Repetitions}}\\
\hline
\endfirsthead
\hline
\multicolumn{3}{|r|}{\small\sl continued on next page}\\
\hline
\endfoot
\endlastfoot
0 h & 1 & 0 h\\
\cline{1-3}
\multicolumn{3}{|p{\dimexpr0.8\linewidth+2\tabcols ep\relax}|}{
\begin{tabu} { | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Intravenous Bolus & \\
\end{tabu}
}\\
\cline{1-3}2.00 h & 5 & 10 h\\
\cline{1-3}
\multicolumn{3}{|p{\dimexpr0.8\linewidth+2\tabcols ep\relax}|}
{\begin{tabu} { | X[1] | X[1] | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Start Time}} & \multicolumn{1}{c|}{\textbf{Dose}} & \multicolumn{1}{c|}{\textbf{Administration type}} & \multicolumn{1}{c|}{\textbf{Placeholder for formulation}}\\
\cline{1-4}0 h & 1.00 mg/kg & Oral & Formulation\\
\cline{1-4}
\multicolumn{4}{|p{\dimexpr0.8\linewidth+2\tabcols ep\relax}|}
{\begin{tabu} { | X[1] | X[1] | }
\multicolumn{1}{|c|}{\textbf{Parameter }} & \multicolumn{1}{c|}{\textbf{Value}}\\
\cline{1-2}Volume of water/body weight & 22.00 ml/kg\\
\end{tabu}
}\\
\cline{1-4}
\end{tabu}
}\\
\cline{1-3}
\hline
\caption{Master Detail Detail Table}
\label{b2bb297be8004446bb38ae83c7107709}
\\
\end{longtabu}
\end{center}
\end{document}
--------------------------------------------------------------------------------
Geändert von ztluw (Heute um 08:46 Uhr) Grund: Inserted answer to question
would give a good looking result in this case, but changing the content of the table brings everything in disorder again.
What can I do to get this done in general?
I would like to use X[-1] also for the sub table columns.
Can anybody explain why TEX cannot produce the requested result? I really do not understand what is happening... :confused:
Powered by vBulletin® Version 4.2.5 Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.