# alignment of fixed width tabs / dnd 4e style stat blocks

I'm trying to replicate DND 4e style creature stat blocks. The plan is first to get something working, then to condense it into a package, then to write a small web-script to generate the latex for stat blocks.

I've been attempting to use fixed width tabular cells for alignment based on the line-width of the page, but this seems to give me some interesting output when cell color is added.

A minimal example of the problem is presented here:

There are two issues that I need to fix. The first is the spacing between each cell (both horizontal and vertical), and the second is the stubbed width of certain lines.

The complete code used to generate the stat block is here:

What seems particularly odd here is that a single cell of 0.9*linewidth is nowhere near the length of a (0.6 + 0.3)*linewidth pair. If there's any difference, one would expect it to be in the order of the tab spacing, but it's nowhere close.

Ideally, a package designed for dealing with this issue would be nice (is this an appropriate use for tabu?), but I'll be happy with any solution or suggestion that works. The plan is to hide most of the messy bits in command definitions anyway.

I managed to do this in a rather hacky way by dunking individual sections of the table into colorboxes (eliminates the backing lines).

Additionally, the full width multicol instances needed to have increased length, presumably to make up for some sort of cell padding.

What I have is actually a terrible solution, which is barely made (generally) usable through ~50 lines of definitions, and still requires manual tuning of some numbers. If anyone can produce a better result, I'll mark you as the answer.

Full code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{hanging}
\usepackage{xcolor,colortbl}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

%%Define colors. Precise color does not matter,
\definecolor{mgreen}{rgb}{0.08,0.35,0.12}
\definecolor{dtangreen}{rgb}{0.80, 0.85, 0.65}
\definecolor{tangreen}{rgb}{0.92, 0.95, 0.8}

%%commands for setting the colors of cells and text
\newcommand{\green}{\cellcolor{mgreen}}
\newcommand{\whiteText}{\color{white}}

\newcommand{\lCell}{\cellcolor{tangreen}}
\newcommand{\dCell}{\cellcolor{dtangreen}}

%%left aligned wide cell
\newcommand{\lwcell}[1]{\multicolumn{3}{L{0.935\linewidth}}{#1}}
%%left aligned and right wide cell
\newcommand{\lrcell}[2]{\multicolumn{2}{L{0.60\linewidth}}{#1} & \multicolumn{1}{R{0.30\linewidth}}{#2}}
%%left aligned and left wide cell
\newcommand{\llwcell}[2]{\multicolumn{1}{L{0.30\linewidth}}{#1} & \multicolumn{2}{L{0.60\linewidth}}{#2}}
%%3x left aligned cells
\newcommand{\lllcell}[3]{\multicolumn{1}{L{0.30\linewidth}}{#1} & \multicolumn{1}{L{0.30\linewidth}}{#2} & #3}

%%creature stat rows:
\newcommand{\statrowA}[3]{\lllcell{\textbf{Str} #1}{\textbf{Dex} #2}{\textbf{Wis} #3}}
\newcommand{\statrowB}[3]{\lllcell{\textbf{Con} #1}{\textbf{Int} #2}{\textbf{Cha} #3}}

%%function for putting tables in colored boxes (hacky). Needs a reverse indent set.
\newcommand{\boxtablen}{-0.7mm}
\newcommand{\boxtab}[2]{\vspace{\boxtablen} \noindent \colorbox{#1}{\begin{tabular}{lll} #2 \end{tabular}}}

%%creature equipment block:
\newcommand{\equipblock}[1]{\boxtab{tangreen}{\lwcell{\lCell \textbf{Equipment} #1}}}

%Single attack for a creature. Use: (attack name/type) (attack properties)
\newcommand{\creatureattackblock}[2]{\boxtab{dtangreen}{\lwcell{\dCell #1}} \par \boxtab{tangreen}{\lwcell{\lCell \hangpara{0.30cm}{0}#2}}}
\begin{document}

Another approach: Try to put everything inside of boxes!

\boxtab{mgreen}{
}

\boxtab{tangreen}{
\llwcell{\lCell \textbf{Initiative} +9}{\lCell \textbf{Senses} Perception +7}\\
\lwcell{\lCell \textbf{HP} 1; a missed attack never damages a minion.}\\
\lwcell{\lCell \textbf{Immune} fear; \textbf{Resist} 10 fire, 10 radiant}\\
\lwcell{\lCell \textbf{Speed} 6, fly 9 (hover)}\\
}

%TODO: rip those icons from the DND books, or find replacement ones!
\creatureattackblock{\textbf{$\bullet$ Slam} (standard; at-will)}{+13 vs. AC; 1d8 + 6 damage}

\boxtab{dtangreen} {
\llwcell{\dCell \textbf{Alignment} Any}{\dCell \textbf{Languages} Common, Goblin}\\
\statrowA{18 (+7)}{18 (+7)}{14 (+5)}\\
\statrowB{16 (+6)}{10 (+3)}{10 (+3)}\\
}

\equipblock{leather armor, morningstar, rope garrote}
\end{document}


One additional thing that may be required is removing paragraph spacing, ie { \parskip 0pt (content) }