Graphics, Figures & TablesColumn width with \multicolumn

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
latexlatexlatex
Posts: 3
Joined: Sun Feb 27, 2011 1:22 am

Column width with \multicolumn

Post by latexlatexlatex »

So I am very close to a good method of making PERT charts using:
1) tabular
2) xypic
3) framebox

However, With tabular it seems only the width of the rightmost collumn is adjusted when adding a \multicolumn row in the table with a length longer than the sum length of the collumns its "merging".

Code: Select all

\framebox{
      \xymatrix{
        {
          \begin{tabular}{|c|c|c|}
            \hline
            1 & 2 & 3 \\ \hline
            \multicolumn{3}{|c|}{activity} \\ \hline
            7 & 8 & 9 \\ \hline
          \end{tabular}
        } \ar[rd] \\ & 
        {
          \begin{tabular}{|c|c|c|}
            \hline
            1 & 2 & 3 \tabularnewline \hline
            \multicolumn{3}{|c|}{activity 2 with a longer line} \tabularnewline \hline
            7 & 8 & 9 \tabularnewline \hline
          \end{tabular}
        }\ar@/^2cm/[ul]
      }
    }
preamble is :

Code: Select all

/documentclass[12pt,a4paper]{article}
\usepackage[left=2cm,top=1.5cm,right=3cm]{geometry}
\usepackage{xypic}
\usepackage{tabulary}

\begin{document} ...
results in:

Image

I was wondering if there was a way of fixing this in tabular? And i want it to be automatically adjusting, not having to manually specify the width of all the collums ;) since that would make the method very time consuming.

apologising for my inability to describe the problem in more detail, im fairly new to latex.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Column width with \multicolumn

Post by localghost »

Provide a minimal example that is compilable as is. Otherwise this will come to nothing.


Best regards and welcome to the board
Thorsten
latexlatexlatex
Posts: 3
Joined: Sun Feb 27, 2011 1:22 am

Column width with \multicolumn

Post by latexlatexlatex »

My bad for not providing a minimum working example x(, I should have known better.

here it is:

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage{xypic}

\begin{document}
\framebox{
  \xymatrix{
    {
      \begin{tabular}{|c|c|c|}
        \hline
        1 & 2 & 3 \\ \hline
        \multicolumn{3}{|c|}{activity} \\ \hline
        7 & 8 & 9 \\ \hline
      \end{tabular}
    } \ar[rd] \\ & 
    {
      \begin{tabular}{|c|c|c|}
        \hline
        1 & 2 & 3 \tabularnewline \hline
        \multicolumn{3}{|c|}{activity 2 with a longer line} \tabularnewline \hline
        7 & 8 & 9 \tabularnewline \hline
      \end{tabular}
    }\ar@/^2cm/[ul]
  }
}
\end{document}
Additional info that might be inportant is that i use pdflatex to compile it, as i need it in pdf form. and I'm not sure if the pdf viewer i use should have any say, but im using evince. (just to get that out there)
pdflatex --version
pdfTeX 3.1415926-1.40.11-2.2 (TeX Live 2010/Arch Linux)
kpathsea version 6.0.0
Copyright 2010 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.4.5; using libpng 1.4.5
Compiled with zlib 1.2.5; using zlib 1.2.5
Compiled with poppler version 0.16.2
could that be important? from pdflatex --version
latexlatexlatex
Posts: 3
Joined: Sun Feb 27, 2011 1:22 am

Re: Column width with \multicolumn

Post by latexlatexlatex »

perhaps there is an alternative to using either /multicolumn or even tabular entirely, will be on the lookout for a solution to this, and will post if i find it. :)

Wonder if anyone else has encountered this before? :S If anyone knows of a better "table making" tool in latex then please tell :P I'm willing to try anything. (It just bugs me when i cannot solve minor visual glitches, and im positive there is a nice solution to it)

In the worst case I guess i could make a command myself that adjusts the size of each column based on some strange formula, since i heard you can do that in latex. (but I'd rather not xP)
Post Reply