tabularx -

Post on 08-Feb-2016

13 Views

Category:

Documents

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

latex.

TRANSCRIPT

sign up log in tour help

×

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.

How to make width of an inner table use full column width of an outer table?How to make width of an inner table use full column width of an outer table?

When making one need to give a table width. For the outermost table, one can use .tabularx \textwidth

When making one or more inner table(s) inside outer table(s), the inner table(s) also need a width, which will be in this case the

width of the column of the outer table that this inner table happened to be in. It is hard to keep track of the the context and to

manually give hardcoded values.

I am not able to figure how to tell LaTeX to use all the available column width from the outer table, and let LaTeX do the

calculation. Need something similar to but for the tablewidth itself.X

Here is a MWE one one table inside another.

\documentclass[10pt,notitlepage]{article}%

\usepackage{tabularx}

\usepackage{hyperref}

\usepackage{array}

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

%have to use tabular* for outer table since I can't figure how to use tabularx

\begin{tabular*}{\textwidth}{|p{0.5\textwidth}|p{0.5\textwidth}|}\hline

\begin{tabularx}{0.5\textwidth}{@{}|Y|Y|Y|@{}}\hline % how to automate this?

% instead of 0.5\textwidth

% use full column width

\href{foo/index.htm}{A}

\begin{enumerate}

\item item 1

\item item 2

\end{enumerate}&

\href{foo/index.htm}{B}&

\href{foo/index.htm}{C}\\\hline

\end{tabularx}

&

second column

\end{tabular*}

\end{document}

{tables} {tabularx}

edited 2 hours ago

Svend Tveskæg

6,7246,7246,7246,724 2 7 47

asked 3 hours ago

Nasser

1,4281,4281,4281,428 1 12

1 Answer

You can use . Useful reference will be: . It would be better to use

for the outer table and a left aligned cell

structure for .

\linewidth this Q and its A

p{\dimexpr0.5\textwidth‐2\tabcolsep\relax}

enumerate

tabularx - How to make width of an inner table use full column width o... http://tex.stackexchange.com/questions/151246/how-to-make-width-of...

1 of 2 12/25/2013 12:55 PM

\documentclass[10pt,notitlepage]{article}%

\usepackage{tabularx}

\usepackage{hyperref}

\usepackage{array}

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

%have to use tabular* for outer table since I can't figure how to use tabularx

\noindent\begin{tabular*}{\textwidth}{|p{\dimexpr0.5\textwidth‐2\tabcolsep\relax}|

@{\extracolsep{\fill}}p{\dimexpr0.5\textwidth‐2\tabcolsep

\relax}|}\hline

\begin{tabularx}{\linewidth}{@{}|p{0.35\hsize}|Y|Y|@{}}\hline % how to automate this?

% instead of 0.5\textwidth

% use full column width

{\centering \href{foo/index.htm}{A}\par}

\begin{enumerate}

\item item 1

\item item 2

\end{enumerate}

&

\href{foo/index.htm}{B}&

\href{foo/index.htm}{C}\\\hline

\end{tabularx}

&

second column

\end{tabular*}

\end{document}

edited 2 hours ago answered 3 hours ago

Harish Kumar

46.7k46.7k46.7k46.7k 2 56 125

– There are other improvisations possible, but I am not sure of what is your final goal. Harish Kumar 3

hours ago

tabularx - How to make width of an inner table use full column width o... http://tex.stackexchange.com/questions/151246/how-to-make-width-of...

2 of 2 12/25/2013 12:55 PM

top related