I want to have a table of width equal to the whole width of the page, I mean, obviously not counting the margins, just the space you are supposed to write in. Right now I'm using the array package and the commands
\newcolumntype{C}[1]{>{\centering\arraybackslash} m{#1\hsize}}
\newcolumntype{L}[1]{>{\arraybackslash} m{#1\hsize}}
To achieve this, if I set something like
{|C{0.14}|C{0.11}|L{0.75}|}
(0.14 + 0.11 + 0.75 = 1\hsize) However the table always overflows into the margin. Is there a way to fix this? Am I doing something wrong with those column types? Here is an example:
\documentclass[11pt,a4paper]{article}
%Packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{parskip}
\usepackage[margin=2cm]{geometry}
\usepackage{array}
\usepackage{lipsum}
%opening
\title{Title}
\author{Pedro Ortiz}
\date{\today}
\begin{document}
\begin{center}
{\Huge\textbf{\textsc{Title}}}
\end{center}
\vspace*{1cm}
\newcolumntype{C}[1]{>{\centering\arraybackslash} m{#1\hsize}}
\newcolumntype{L}[1]{>{\arraybackslash} m{#1\hsize}}
\begin{tabular}{|C{0.14}|C{0.11}|L{0.75}|}
\hline
\textbf{First title} & \textbf{Title} & \multicolumn{1}{>{\centering\arraybackslash} m{0.75\hsize}|}{\textbf{Very Large Title} }\\
\hline
Some text that I decided to put here & \LaTeX & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien
est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinarat, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci egetrisus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.\\
\hline
More text that I decided to put here & \LaTeX & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien
est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinarat, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci egetrisus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.\\
\hline
Even more text that I decided to put here & \LaTeX & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien
est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinarat, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci egetrisus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.\\
\hline
\end{tabular}
\end{document}
The tabularx package does not solve my problem, I also need the width to be customizable, if I want a table of three columns to be half of the width of the line, where the first column is of width .3(width of line) and the second and third are 0.1(width of line) it won't work. The X environment is also not appropriate for this as I need control over both the width and the text placement in each cell. I am sure there is a way to solve the width problem by redefining:
\newcolumntype{C}[1]{>{\centering\arraybackslash} m{#1\hsize}}
\newcolumntype{L}[1]{>{\arraybackslash} m{#1\hsize}}
But I don't know how to do it.
Xcolumns in the specifications of\newcolumntypeas well and thereby changing the alignment – Apr 15 '18 at 16:50tabularxpackage. E.g., your table could be set up via the statement\begin{tabularx}{0.5\textwidth}{| >{\hsize=1.8\hsize}X | >{\hsize=0.6\hsize}X | >{\hsize=0.6\hsize}X |}. Observe that1.8+0.6+0.6=3, which is the number of columns of typeXin thistabularxenvironment, and that1.8=3*0.6. – Mico Apr 15 '18 at 17:11mcolumns – David Carlisle Apr 15 '18 at 17:11{|C{0.15}|C{0.125}|L{0.645}|supposed to achieve? – Mico Apr 15 '18 at 17:14\newlength\myhsize \setlength\myhsize{\dimexpr \hsize - 6\tabcolsep - 4\arrayrulewidth} \newcolumntype{C}[1]{>{\centering\arraybackslash} m{#1\myhsize}} \newcolumntype{L}[1]{>{\arraybackslash} m{#1\myhsize}}Works, thank you for pointing me to the right answer! – pjox Apr 15 '18 at 17:35X-type columns. AFAICT, those two issues are entirely independent of each other. – Mico Apr 15 '18 at 17:36\tabcolsepand\arrayrulewidth, so changing the margins could make the table overflow or underflow. I've had that problem multiple times. – pjox Apr 15 '18 at 17:39