3

I would like to create a T-account as the ones represented in this image:

enter image description here

I have tried to do this using the table environment, without good results (when for example I have words/numbers only on one side of the account, say left, all the space on the other side (right) is removed).

Maybe a workable solution is to use the minipage environment with two columns inside?

Any advice appreciated!

\documentclass{article}

\begin{document}

\begin{table}[]
\centering
%\caption{My caption}
\label{my-label}
\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|c|}{Statement of Income 2015} \\ \hline
Debit                     & Credit             \\ \hline
Increase                  & Decrease           \\ \hline
Normal Balance            &                    \\ \hline
\end{tabular}
\end{table}

\end{document}
3
  • It would be good to provide a working example code (especially so since you have attempted it already), so that we can help you improve on it, or otherwise suggest a better alternative. – Troy Jan 31 '17 at 16:52
  • This is pretty easy with a \multicolumn approach and wrapping column types – user31729 Jan 31 '17 at 16:53
  • @ChristianHupfer Could you please further develop my MWE? – Francesco Bianchi Jan 31 '17 at 16:58
4

The definition below introduces the macro

\Taccount[column width]{headline}{table contents}

The first argument is optional and defaults to 1.5cm.

\newcommand\Taccount[3][1.5cm]%
   {{\renewcommand\arraystretch{1.3}%
    \begin{tabular}[t]{@{}p{#1}|p{#1}@{}}
    \multicolumn{2}{@{}c@{}}{#2}\\
    \hline
    #3
    \end{tabular}%
   }}

The spacing between rows is controlled by \arraystretch, which is increased here to 1.3.

enter image description here

\documentclass{article}
\newcommand\Taccount[3][1.5cm]%
   {{\renewcommand\arraystretch{1.3}%
    \begin{tabular}[t]{@{}p{#1}|p{#1}@{}}
    \multicolumn{2}{@{}c@{}}{#2}\\
    \hline
    #3
    \end{tabular}%
   }}
\begin{document}
\Taccount{Assets}{Debits&Credits\\Increase&Decrease\\Normal Balance}\quad
\Taccount{Expenses}{Debits&Credits\\Increase&Decrease\\Normal Balance}\quad
\Taccount{Owner's Drawing}{Debits&Credits\\Increase&Decrease\\Normal Balance}
\bigskip

\Taccount{Liabilities}{Debits&Credits\\Decrease&Increase\\&Normal Balance}\quad
\Taccount{Revenues}{Debits&Credits\\Decrease&Increase\\&Normal Balance}\quad
\Taccount{Owner's Capital}{Debits&Credits\\Decrease&Increase\\&Normal Balance}
\end{document}
2
  • Is there a way to change the width for a single T-Account? By putting the TaccountWidth in the preamble it influences all the T-scheme created in the document with a fixed width. I would like to change it arbitrarily with respect to the content of each T-Accounts. – Francesco Bianchi Feb 2 '17 at 9:21
  • @FrancescoBianchi I've added an optional parameter for the width of the columns. In fact, this makes the definition a bit simpler. – gernot Feb 2 '17 at 10:17
2

(edited to take into account the OP's wish to be able to override the default width of a t-account)

Here's an answer that defines a macro, called \taccount, which takes four arguments, the first of which is optional:

  • the width of each t-column; this argument is optional. If left unspecified it will default to \tcolumnwidth (set to 1.75cm in the code below)
  • the account header (centered, automatic line-wrapping enabled)
  • the material for the left-hand ("asset") column (ragged-right, line-wrapping enabled, hyphenation is allowed)
  • the material for the right-hand ("liability") column (also ragged-right, line-wrapping enabled, hyphenation is allowed)

enter image description here

\documentclass{article}
\usepackage{array,ragged2e}
\newlength\tcolumnwidth
\setlength\tcolumnwidth{1.75cm} % default width of t-column
\newlength\taccountwidth

%% The macro "\taccount" takes 4 arguments. The first
%% arg. is optional; its default value is \tcolumnwidth.
\newcommand\taccount[4][\tcolumnwidth]{% 
  \renewcommand\arraystretch{1.333} % default value: 1
  \setlength\tabcolsep{3pt}         % default value: 6pt
  \setlength\taccountwidth{\dimexpr#1+#1+2\tabcolsep+1\arrayrulewidth\relax}
  \begin{tabular}[t]{@{}l|l@{}}
  \multicolumn{2}{>{\Centering}p{\taccountwidth}}{#2}\\
  \hline
  \begin{tabular}[t]{@{}>{\RaggedRight\hspace{0pt}}p{#1}} 
  #3 \end{tabular} 
  &
  \begin{tabular}[t]{>{\RaggedRight\hspace{0pt}}p{#1}@{}} 
  #4 \end{tabular}
  \end{tabular}}

\begin{document}
% First instance of \taccount uses the default width;
% the second instance uses a non-default width.
\taccount{A basic T-account}
  {Asset 1\\Asset 2\\Asset 3\\Asset 4}
  {Liability 1\\Liability 2\\ Equity}
\qquad     
\taccount[2.75cm]{A slightly more complicated T-account}
  {Basic Asset 1\\Complicated Asset 2\\Asset 3\\Asset 4}
  {Liability 1\\Complicated Liability 2\\Preferred Stock\\Common Equity}

\end{document}
2
  • Is there a way to change the width for a single T-Account? By putting the TaccountWidth in the preamble it influences all the T-scheme created in the document with a fixed width. I would like to change it arbitrarily with respect to the content of each T-Accounts. – Francesco Bianchi Feb 2 '17 at 9:22
  • @FrancescoBianchi - I've modified the code of the \taccount macro so that it takes an additional, optional argument, viz., the width of each t-column. – Mico Feb 2 '17 at 10:02

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.