Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to create a table with two columns which follow the rules of the golden ratio. The width of the table should be equal to \textwidth of the corresponding class.

Here is an example image:

enter image description here

But instead of 960px it should use the full textwidth.

Edit:

As the image is not really clear I need to clarify my requirements. I'd like to have a little space between the two columns which will not be included in the calculation of the golden ratio. For example if the pagewidth would be 1000px and the space between is 40px the golden ratio should be calculated from the 960px. And additionally I don't want to have any padding on the left and the right side of and inside the columns.

share|improve this question
    
How about just using \begin{tabular}{p{0.618\textwidth}p{0.382\textwidth}}? –  Jake Aug 14 '12 at 7:21
    
@Jake There you get into troubles with \tabcolsep... –  tohecz Aug 14 '12 at 7:26
    
Indeed, it's not quite clear how the 'borders' are supposed to be handled. @Marco Do you want the whitespace between columns, and if so what how should it be accounted for? –  Joseph Wright Aug 14 '12 at 7:31
    
@JosephWright The image I took is from the internet and I have to admit that it is not really clear. I'll just edit the question. –  Marco Aug 14 '12 at 7:51

3 Answers 3

up vote 3 down vote accepted

The following example is taken from the manual to tabularx package, just the width are set so that w1/w2=golden ratio and w1+w2=2. For details why this, see the manual. Let us note that the package lipsum and command \lipsum[2] are there to provide some dummy text.

\documentclass{article}

\usepackage{tabularx}
\usepackage{lipsum}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{}>{\hsize=1.23607\hsize}X@{}>{\hsize=0.76393\hsize}X@{}}
\lipsum[4] & \lipsum[2] 
\end{tabularx}

\end{document}

Edit: as specified by OP, I added @{} 3 times to the column specification of the table to remove the horizontal padding completely.

share|improve this answer
    
Thank you for your answer but I'd like to have a little space between the two columns whose width won't be considered in the calculation of the golden ratio. –  Marco Aug 15 '12 at 5:58
    
@Marco Then simply remove @{} between X and >, like this: \begin{tabularx}{\textwidth}{@{}>{\hsize=1.23607\hsize}X>{\hsize=0.76393\hsize}‌​X@{}} –  tohecz Aug 15 '12 at 6:13

One could use tabu which provides a mechanism to give fractions in the column declaration:

\documentclass{book}
\usepackage{tabu}

\begin{document}


\noindent\begin{tabu} to \textwidth{|X[0.618]|X[0.382]|}
long 61.8 \% & short 38.2\% \\
\end{tabu}


\end{document}
share|improve this answer
    
Thank you for your answer but is there a possibility to remove any padding inside the columns and instead add a third column in the middle? The width of this third column should not be taken into consideration when calculating the width of the golden ratio. –  Marco Aug 15 '12 at 6:00

Define a new length, subtract \tabcolsep, and use this length as basis for your calculations:

\documentclass{article}

\begin{document}

\newlength{\mytabwidth}
\setlength{\mytabwidth}{\textwidth}
\addtolength{\mytabwidth}{-\tabcolsep}

% display the new table width
\the\mytabwidth

\begin{tabular}{|@{}p{0.618\mytabwidth}|p{0.382\mytabwidth}@{}|}
 \hline
 a \hfill a  & b \hfill b \\
 \hline
\end{tabular}
\end{document}
share|improve this answer
1  
I believe that this is the correct way of thinking. However, it would not work in the current version. You have to think about the width of the vertical lines, even these lines have some seperation from the cells, and the whole table has some margins. I believe that complications with these calculations are one of the reasons why packages like tabu or tabularx exist... –  tohecz Aug 14 '12 at 9:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.