Math & Sciencecreate a chart

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

create a chart

Post by michael_b »

Hello everybody

i have to create a chart in latex and hope that you can help me.

the chart has to look like:
chart.jpg
chart.jpg (46.63 KiB) Viewed 3459 times
how can i realise that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

create a chart

Post by php1ic »

Hi micheal_b,

The way I would do it would be to imagine that every square on the paper in your example represents a column or row then only put in lines when appropriate.

You will need to use \multicolumn and \cline commands. I'm busy at the moment so have only done a small example to get you started. If you don't understand anything please ask.

Code: Select all

\documentclass{article}
\usepackage{slashbox,multirow}
\begin{document}
\begin{tabular}{|ccc|}
\hline
\multicolumn{1}{|c|}{A}&&\\
\cline{1-1}
&$x_{12}$&\\
&&\\
\hline
\multicolumn{3}{|c|}{\multirow{3}{*}{\backslashbox{20}{20}}}\\ && \\ &&\\
\hline
\end{tabular}
\end{document}
I found the slashbox package through google and it can be downloaded here. It isn't perfect but is a good start
http://www.tex.ac.uk/tex-archive/macros ... /slashbox/
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

create a chart

Post by michael_b »

hi php1ic!

thank you for the quick answer.

i have no problems to add new boxes in one way. But how can i add new splits?

My code looks now like that:

Code: Select all

\documentclass{article}
\usepackage{slashbox,multirow}
\begin{document}
\begin{tabular}{|ccc|}
\hline
\multicolumn{1}{|c}{}&&\\
&$B_1$&\\
&&\\
\hline
\hline
\multicolumn{1}{|c|}{2}&&\\
\cline{1-1}
&$x_{11}$&\\
&&\\
\hline
\multicolumn{1}{|c|}{2}&&\\
\cline{1-1}
&$x_{21}$&\\
&&\\
\hline
\multicolumn{1}{|c|}{1}&&\\
\cline{1-1}
&$x_{31}$&\\
&&\\
\hline
\multicolumn{1}{|c}{}&&\\
&$10$&\\
&&\\
\hline
\end{tabular}
\end{document}
Additionally, is there a possibility to pick e.g. the x_11 to the head of the box so that the x_11 are beside the number?
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

create a chart

Post by php1ic »

I assume by splits you mean columns. To do that you need to put more arguments when you start the tabular environment

Code: Select all

\begin{tabular}{|ccc|ccc|ccc|}
each letter 'c' represents a column containing centered text (r - right aligned, l - left). The code below almost reproduces the table you want but maths mode cannot be used with \multirow so you may want to continue constructing the table by extending the code you posted.

Code: Select all

\begin{tabular}{cc|cc|cc|ccc}
&&\multicolumn{2}{|c|}{B{\tiny 1}}&\multicolumn{2}{|c|}{B{\tiny 2}}&\multicolumn{3}{|c}{a{\tiny i}}\\
\hline
\multicolumn{2}{c|}{\multirow{2}{*}{A{\tiny 1}}}&\multicolumn{1}{|c|}{1}&$x_{11}$&\multicolumn{1}{|c|}{2}&$x_{12}$&\multicolumn{3}{c}{\multirow{2}{*}{ 10 }}\\
\cline{3-3}\cline{5-5}
&&&&&&\\
\hline
\multicolumn{2}{c|}{\multirow{2}{*}{A{\tiny 2}}}&\multicolumn{1}{|c|}{3}&$x_{21}$&\multicolumn{1}{|c|}{4}&$x_{22}$&\multicolumn{3}{c}{\multirow{2}{*}{ 10 }}\\
\cline{3-3}\cline{5-5}
&&&&&&\\
\hline
\multicolumn{2}{c|}{\multirow{2}{*}{b{\tiny i}}}&\multicolumn{2}{c|}{\multirow{2}{*}{10}}&\multicolumn{2}{c|}{\multirow{2}{*}{10}}&\multicolumn{3}{c}{\multirow{2}{*}{\backslashbox{20}{20}}}\\
&&&&&\\
\end{tabular}
to put x_11 at the top for your example, simply move it up one cell ie

Code: Select all

\hline
\multicolumn{1}{|c|}{2}&$x_{11}$&\\
\cline{1-1}
&&\\
&&\\
\hline
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

Re: create a chart

Post by michael_b »

Yes you are right, i mean columns. Well thank you very much for your help. I have extend the code for another example and it looks great. :)
Post Reply