會計T型帳戶計劃

會計T型帳戶計劃

我想建立一個 T 帳戶,如下圖所示:

在此輸入影像描述

我嘗試使用表格環境來執行此操作,但沒有好的結果(例如,當我僅在帳戶的一側(例如左側)有單字/數字時,另一側(右側)的所有空間都被刪除)。

也許一個可行的解決方案是使用minipage內部有兩列的環境?

任何建議表示讚賞!

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

答案1

(編輯考慮到 OP 希望能夠覆蓋 t 帳戶的預設寬度)

下面的答案定義了一個名為 的宏\taccount,它有四個參數,第一個參數是可選的:

  • 每個 t 柱的寬度;此參數是可選的。如果未指定,則預設為(在下面的程式碼中\tcolumnwidth設定)1.75cm
  • 帳戶標題(居中,啟用自動換行)
  • 左側(「資產」)列的材質(右側參差不齊,啟用換行,允許連字號)
  • 右側(「責任」)列的材質(也為右側參差不齊,啟用換行,允許連字號)

在此輸入影像描述

\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

下面的定義介紹了宏

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

第一個參數是可選的,預設為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}%
   }}

行之間的間距由 控制\arraystretch,此處增加到1.3

在此輸入影像描述

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

相關內容