3

When making tabularx one need to give a table width. For the outermost table, one can use \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 X but for the tablewidth itself.

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}

Mathematica graphics

2

You can use \linewidth. Useful reference will be: this Q and its A. It would be better to use p{\dimexpr0.5\textwidth-2\tabcolsep\relax} for the outer table and a left aligned cell structure for enumerate.

\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}

enter image description here

| improve this answer | |
  • There are other improvisations possible, but I am not sure of what is your final goal. – user11232 Dec 25 '13 at 2:46
1

see if this is what you like to achieve:

\documentclass[10pt,notitlepage]{article}%
\usepackage{array,tabularx,hyperref}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
 \begin{document}
\begin{tabularx}{\textwidth}{|@{}X@{}|X|}%outer table, @{} omit column separation 
    \hline
    {\begin{tabularx}{\hsize}{|Y|Y|Y|}
    \hline
\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{tabularx}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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