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 attempting to make a figure in TikZ which I want to look like this: fig

I have been able to come up with something close in TikZ, but I would really like to have the above figure instead of my solution.

\usepackage[usenames,dvipsnames]{color}
\usepackage{tikz}
\usepackage{booktabs}
\usetikzlibrary{shapes,arrows}

\tikzstyle{block3} = [rectangle, draw, fill=green!20,
text width=15em, text centered, minimum height=4em]
\tikzstyle{block4} = [rectangle, draw, fill=purple!20,
text width=12em, text centered, minimum height=4em]
\tikzstyle{block5} = [rectangle, draw, fill=red!20,
text width=9em, text centered, minimum height=4em]

\begin{document}

\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}
% Place nodes
\node [block3,align=center,xshift=-30em] (as) {ASSETS \hline \\{\color{cyan}Cash + Accounts Receivable + Prepaid Insurance + Equipment + Truck}};
\node [draw=white] at (-7.5,0) (equal) {=};
\node [block4,align=center,right of=as,xshift=13em] (li) {LIABILITIES \hline\\{\color{purple}Bank Loan + Accounts Payable + Unearned Revenue}};
\node [draw=white] at (-2.3,0) (plus) {+};
\node [block5,align=center,right of=li,xshift=11em] (eq) {EQUITY \hline     \\{\color{red}Share Capital + Retained Earnings}};
% Draw edges
\end{tikzpicture}
\end{center}
\end{figure}

\end{document}

assets

share|improve this question
2  
Always post complete code i.e. a small, compilable document. As posted, your code will not compile. A complete, small document is much more useful than mere fragments which leave helpers to guess you document class and the packages required to compile. You even leave potential helpers to add \begin{document}... \end{document} themselves! –  cfr May 31 at 22:46
    
Have you looked at tcolorbox? –  cfr May 31 at 23:32

2 Answers 2

up vote 9 down vote accepted

You don't need tikz for this. A simple tabular will do.

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array,booktabs}
\newcommand{\head}[1]{%       %% code stolen from egreg
  \begin{tabular}{@{}c@{}}
  \strut#1\strut
  \end{tabular}%
}
\newcolumntype{C}{>{\columncolor{cyan!20}\color{cyan}}c}
\newcolumntype{B}{>{\columncolor{blue!10}\color{blue}}c}
\newcolumntype{R}{>{\columncolor{red!10}\color{red}}c}
\begin{document}
\noindent
{\footnotesize
  \begin{tabular}{CcBcR}
   ASSETS & $=$ & LIABILITIES & $+$ &  EQUITY \\\noalign{\vspace{-2pt}} \cmidrule[1pt]{1-1}\cmidrule[1pt]{3-3}\cmidrule[1pt]{5-5}\noalign{\vspace{-3pt}}
Cash $+$ \head{Accounts \\ Receivable} $+$ \head{Prepaid \\Insurance} $+$ Equipment $+$ Truck
 & $=$ &
 \head{Bank \\ Loan} $+$ \head{Accounts \\ Payable} $+$ \head{Unearned \\ Revenue}
 & $+$ &
 \head{Share \\ Capital} $+$ \head{Retained \\ Earnings}
  \end{tabular}
}
\end{document}

enter image description here

If you want to align the symbols at the top:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array,booktabs}
\newcommand{\head}[1]{%       %% code stolen from egreg
  \begin{tabular}{@{}c@{}}
  \strut#1\strut
  \end{tabular}%
}
\newcolumntype{C}{>{\columncolor{cyan!20}\color{cyan}}c}
\newcolumntype{B}{>{\columncolor{blue!10}\color{blue}}c}
\newcolumntype{R}{>{\columncolor{red!10}\color{red}}c}
\begin{document}
\noindent
{\footnotesize
  \begin{tabular}{CcBcR}
   ASSETS & $=$ & LIABILITIES & $+$ &  EQUITY \\\noalign{\vspace{-2pt}} \cmidrule[1pt]{1-1}\cmidrule[1pt]{3-3}\cmidrule[1pt]{5-5}\noalign{\vspace{-3pt}}
\head{Cash \\} \head{$+$ \\} \head{Accounts \\ Receivable} \head{$+$ \\} \head{Prepaid \\Insurance} \head{$+$ \\} \head{Equipment\\} \head{$+$ \\} \head{Truck\\}
 & \head{$=$\\} &
 \head{Bank \\ Loan} \head{$+$ \\} \head{Accounts \\ Payable} \head{$+$ \\} \head{Unearned \\ Revenue}
 & \head{$+$ \\} &
 \head{Share \\ Capital} \head{$+$ \\} \head{Retained \\ Earnings}
  \end{tabular}
}
\end{document}

enter image description here

share|improve this answer
    
Thanks for your help, looks great Harish! –  Samuel Reid Jun 1 at 17:07
    
+1 I didn't know xcolor had a table option. This looks really useful. I prefer this to my answer as I think it will get the alignment right in a wider range of cases. –  cfr Jun 1 at 19:09

For example, you might try something along these lines if you took the tcolorbox route. This code defines a new command \mybox which takes one optional and two mandatory arguments. (This is based on the tcolorbox manual's examples.) The optional argument specifies the main colour. The first mandatory argument specifies the title and the second the main body of the box. You can then use a normal tabular environment or whatever you prefer to set out the contents of the main part of the box. \myinterbox takes exactly one argument which is the symbol you want to use in between two boxes.

\documentclass[landscape]{article}
\usepackage{geometry}
\usepackage{tcolorbox}

\newtcbox{mybox}[2][black]{%
  colback=#1!10!white, colbacktitle=#1!10!white, coltitle=#1!70!black, title={#2}, fonttitle=\bfseries\sffamily, center title, center upper, colupper=#1!70!black, fontupper=\bfseries\sffamily, arc=0pt, boxrule=0pt, titlerule=.5mm, leftupper=0pt, rightupper=0pt, bottom=0pt, top=0pt, nobeforeafter}
\newcommand*{\myinterbox}[1]{%
  \tcbox[colback=white, center upper, colupper=black, fontupper=\bfseries\sffamily, arc=0pt, boxrule=0pt, titlerule=0pt, leftupper=0pt, rightupper=0pt, bottom=0pt, top=0pt, nobeforeafter]{\begin{tabular}{c}#1\\#1\\\mbox{ }\\\end{tabular}}}


\begin{document}

\noindent\mybox[green]{ASSETS}{%
  \setlength{\tabcolsep}{1pt}%
  \begin{tabular}{*{9}{c}}
    & + & Accounts & + & Prepaid & + & Equipment & + & Truck\\
   Cash & & Receivable & & Insurance & & & &
  \end{tabular}}
\myinterbox{=}
\mybox[blue]{LIABILITIES}{%
  \setlength{\tabcolsep}{1pt}%
  \begin{tabular}{*{5}{c}}
    Bank & + & Accounts & + & Unearned\\
    Loan & & Payable & & Revenue
  \end{tabular}}
\myinterbox{+}
\mybox[red]{EQUITY}{%
  \setlength{\tabcolsep}{1pt}%
  \begin{tabular}{*{3}{c}}
    Share & + & Retained\\
    Capital & & Earnings
  \end{tabular}}

\end{document}

Coloured boxes

share|improve this answer
    
This looks great although I couldn't get tcolorbox to work, so I accepted the other answer. –  Samuel Reid Jun 1 at 17:06
    
Do you mean my code failed for you? Or something else went wrong? –  cfr Jun 1 at 17:22
    
Yes, for some reason the tcolorbox.sty wouldn't load, I installed it through MikTex and then manually and for some reason it wouldn't load through Kile. It's just my own problem, I'm sure your code works when tcolorbox works. –  Samuel Reid Jun 1 at 18:41
    
@SamuelReid Oh, I see. Yes, that does sound like one problem which I'm not to blame for! I'm using TeX Live so I'm not much help with MiKTeX but there are questions around about the package manager. Otherwise, I'd open a new question if you can't sort the issue out yourself. I think Harish Kumar's answer is better than mine anyway so I wouldn't worry for this particular case. His will align things correctly in cases where mine will not (or will not without fiddling). –  cfr Jun 1 at 19:07

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.