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 am trying to create a RPG "character sheet" using LaTeX. For those unfamiliar with the madness of nested boxes, underlined whitespace etc. involved, this here gives a good impression (except that I want mine to look better, of course. ;-) )

I started with a \begin{tabularx{\textwidth}}{|X|X|X|}, and tried to nest tabular and tabularx ennvironments in that, intending to use \hrulefill to get the underlines.

The problem is, I'd like to make the nested tables as wide as the enclosing table cell allows, but don't know how to get to that value. 0.33\textwidth is only a rough guesstimate, and does not take into account cell padding and the like.

After looking at the tabularx documentation, I tried \TX@cell@width, but that gave me an error ("undefined control sequence").

Is there a way to get a value like \cellwidth or something, for the width definition of a nested tabularx? Or a package specialized for this kind of work? (I tried the MiKTeX package manager looking for something like it, but came up empty.)

Edit: Ups... forgot the MWE...

\documentclass{scrbook}

\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
{ \begin{tabularx}{\TX@col@width}{lX}  %% <-- this does *not* work...
Name: & \hrulefill\\
Race: & \hrulefill\\
Profession: & \hrulefill\\
\end{tabularx} } &
\Large\textbf{Character Sheet} &
Empty so far\\
\hline
\end{tabularx}
\end{document}
share|improve this question
add comment

2 Answers

up vote 4 down vote accepted
\documentclass{scrbook}

\usepackage{tabularx}
\makeatletter
\newcommand\cellwidth{\TX@col@width}
\makeatother

\begin{document}

\begin{tabularx}{\textwidth}{|X|X|X|}
\hline
{\begin{tabularx}{\cellwidth}{lX}  %% <-- this does *not* work...
Name: & \hrulefill\\
Race: & \hrulefill\\
Profession: & \hrulefill\\
\end{tabularx}}&
\Large\textbf{Character Sheet} &
Empty so far\\
\hline
\end{tabularx}
\end{document}

You can't use @-commands without protecting them between \makeatletter and \makeatother; it's best to do it beforehand. Note that the command is \TX@col@width.

share|improve this answer
    
Works like a charm! –  DevSolar Oct 6 '11 at 11:45
add comment

why do you need the cell width? \hrulefill already works:

\begin{tabularx}{\textwidth}{|X|X|X|}
foo \rule{1cm}{0.4pt} \hrulefill &foo \hrulefill &foo \hrulefill
\end{tabularx}

However, in this case the columnwidth is \dimexpr \textwidth/3-6\tabcolsep

share|improve this answer
    
Sorry, I forgot to include the MWE in the example. I think it makes it clearer what I want to do - having the underlines start at the same horizontal position. \hrulefill only fills space that is already there... but I was also asking about the general case. –  DevSolar Oct 6 '11 at 11:09
    
6\tabcolsep? That cuts the lines rather short... I get correct-looking results with 3\tabcolsep...? –  DevSolar Oct 6 '11 at 11:15
add comment

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.