1

I'm trying to create some T-account-tables. This is my code:

\documentclass[10pt,draft,oneside,titlepage]{report}
\usepackage[a4paper, left=2cm, right=2cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{ngerman}
\usepackage[natural,table]{xcolor}
\usepackage{float}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}

\newcommand{\tableTAccount}[4]{
\begin{figure}[H]
\caption{#1}
\scriptsize
\setlength{\tabcolsep}{3pt}
\begin{tabular}{
p{1.27cm}
p{0.69cm}
p{1.8cm}
p{2cm}
>{\raggedleft}p{1.55cm}|
p{1.27cm}
p{0.69cm}
p{1.8cm}
p{2cm}
>{\raggedleft}p{1.55cm}
}
    \multicolumn{4}{l}{Soll} & \multicolumn{2}{c}{#2} & \multicolumn{4}{r}{Haben} \\ \hline
    #3
    \multicolumn{5}{r|}{} & \multicolumn{5}{r}{} \\
    #4
\end{tabular}
\end{figure}
}

\newcommand{\addRowTTA}[2]{#1 & #2 \\}

\newcommand{\addRowEntryTTA}[5]{#1 & #2 & #3 & #4 & #5}

\newcommand{\addRowEmptyEntryTTA}{&&&&}

\newcommand{\addRowTTAResults}[3]{
\multicolumn{5}{r|}{#1} & \multicolumn{5}{r}{#2} \\
\multicolumn{5}{r|}{} & \multicolumn{5}{r}{#3} \\
}

\begin{document}

\tableTAccount
{T-Account}
{account}
{
\addRowTTA
    {\addRowEmptyEntryTTA}
    {\addRowEntryTTA{1}{2}{3}{4}{12.36}}
}
{\addRowTTAResults{0}{12.36}{12.36}}

\end{document}

resulting in:

! Misplaced \omit.
\multispan ->\omit 
               \@multispan 
l.56     {\addRowTTAResults{0}{12.36}{12.36}}

When I swap the following lines

{\addRowEntryTTA{1}{2}{3}{4}{12.36}} 
{\addRowEmptyEntryTTA}

it works. But i want to be able, to use every possible combination out of \addRowEntryTTA and \addRowEmptyEntryTTA to build multiple \addRowTTA.

If I don't use >{\raggedleft} it works too, but I need to have a certain layout.

What is the cause of the error?

1

1 Answer 1

1

\raggedleft redefines \\ to mean a ragged text line break and so that stops it having its end of table row meaning.

Either use \tabularnewline instead of \\ to end the table row (this is the saved normal definition of \\ inside tables) or use \raggedleft\arraybackslash then you can use \\ again as \arraybackslash redefines \\ to have its array/tabular meaning.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .