3
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{1.2}
\centering
\setlength\tabcolsep{0.5em}
\scalebox{0.84}
{
\begin{tabular}{|l|l|l|}
\hline
Items & Type & Description\\
\hline
Output & Integrated Application & ABC\\
\hline
& Process \& Element Definition & AVB\\
\hline
& Tasks & PWS\\
\hline
& S & X Queries\\
\hline
& Scripting Languages & Java Script or VB Script\\
\hline
& Message Start Events & Receive or reply events\\
\hline 
Software & GUI tools & IBP\\
\hline
People & Designers & IDP\\
\hline
& Developers & PER\\
\hline
Technique & AAD\\
\hline
& Integration & ERCFT\\
\hline
& Task & ETY\\
\hline
\end{tabular}
}
\caption{TYURGY}
\label{t1}
\end{table}
\end{document}

I have tried to merge the contents of table cell using multirow, but it is not giving the output as desired. I want all the cells (rows) of column 1 (Items) to be merged into a single (wrap) row for the value Output. The MWE is as follows. Any help is appreciated.

4
  • Which cells are you trying to merge?
    – Mico
    Commented Jun 3, 2016 at 18:02
  • I've taken the liberty of editing your code to make it compilable. Please do clarify which cells should be merged.
    – Mico
    Commented Jun 3, 2016 at 18:10
  • 1
    A nested tabular perhaps?
    – user31729
    Commented Jun 3, 2016 at 18:10
  • 2
    note that apart from the merging, scaling tables is usually a bad idea but if you do do it beware white space \scalebox{0.84} { \begin{tabular} will put a white space 84% the width of a inter-word space to the left of the table Commented Jun 3, 2016 at 18:28

2 Answers 2

3

Here I do it with left-aligned \Longunderstacks.

\documentclass{article}
\usepackage{graphicx,stackengine}
\setstackEOL{/}
\setstackgap{L}{\normalbaselineskip}
\strutlongstacks{T}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{1.2}
\centering
\setlength\tabcolsep{0.5em}
\scalebox{0.84}
{
\begin{tabular}{|l|l|l|}
\hline
Items & Type & Description\\
\hline
Output & \Longunderstack[l]{Integrated Application/ Process \& Element Definition/
  Tasks/ S/ Scripting Languages / Message Start Events}
& \Longunderstack[l]{ABC/ AVB/ PWS/ X Queries/ Java Script or VB Script/ 
  Receive or reply events}\\
\hline
Software & GUI tools & IBP\\
\hline
People & \Longunderstack[l]{Designers/ Developers} 
& \Longunderstack[l]{IDP/PER}\\
\hline
Technique & \Longunderstack[l]{AAD /Integration/ Task}
& \Longunderstack[l]{/ERCFT/ ETY} \\
\hline
\end{tabular}
}
\caption{TYURGY}
\label{t1}
\end{table}
\end{document}

enter image description here

ADDENDUM (How not to emulate \cline inside of a stack)

The OP asked about this, and I said there are better ways, since the stack, being inserted inside the tabular environment, really has no way of knowing how wide the column is, or the placement of its contents relative to the tabular cell border.

But just to show how it is done, the lines marked %%%... in the code replace the entry "S", so that a properly sized \cline may be placed under it.

\documentclass{article}
\usepackage{graphicx,stackengine}
\setstackEOL{/}
\setstackgap{L}{\normalbaselineskip}
\strutlongstacks{T}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{1.2}
\centering
\setlength\tabcolsep{0.5em}
\scalebox{0.84}
{
\begin{tabular}{|l|l|l|}
\hline
Items & Type & Description\\
\hline
Output & \Longunderstack[l]{Integrated Application/ Process \& Element Definition/
  Tasks/ 
  \def\stackalignment{l}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \setbox0=\hbox{Process \& Element Definition}%%%%%%%%%
  \stackunder[2pt]{S}{\llap{\rule{\tabcolsep}{.3pt}}%%%%
  \rlap{\rule{\dimexpr\wd0+\tabcolsep}{.3pt}}}/ %%%%%%%%
  Scripting Languages / Message Start Events}
& \Longunderstack[l]{ABC/ AVB/ PWS/ X Queries/ Java Script or VB Script/ 
  Receive or reply events}\\
\hline
Software & GUI tools & IBP\\
\hline
People & \Longunderstack[l]{Designers/ Developers} 
& \Longunderstack[l]{IDP/PER}\\
\hline
Technique & \Longunderstack[l]{AAD /Integration/ Task}
& \Longunderstack[l]{/ERCFT/ ETY} \\
\hline
\end{tabular}
}
\caption{TYURGY}
\label{t1}
\end{table}
\end{document}

enter image description here

4
  • 1
    This I've never seen. Cool to have a different approach.
    – Runar
    Commented Jun 3, 2016 at 21:02
  • Thanks @Steven.. But, how to put line similar to c-line of booktabs in \Longunderstack environment.
    – M S
    Commented Jun 4, 2016 at 6:21
  • 1
    @SibaMishra Since \Longunderstack is not part of the surrounding tabular environment, there is no easy way to do this, since the stack has no idea how wide the column is, into which it has been placed. That said, there are complicated ways to fake it, but by that point, there are likely better alternatives without the stack. If I get a chance, I may add an addendum to show the complicated way (not to do it). Commented Jun 4, 2016 at 12:35
  • 1
    @SibaMishra See my edit for the promised lesson on how not to emulate \cline inside of a stack. Commented Jun 6, 2016 at 16:14
4

I have here added a solution without multirow, and edited the code with some more common practices in LaTeX, generally acknowledged as a more professional look, and easier to read.

This solution uses booktabs, and the advice contained in that documentation to never use vertical lines, and also some horizontal lines with different widths. The scaleboxshould rarely be used to scale a whole table, as it leads to very inconsistent font-sizes. You could very well use different table column seperation-lengths as you did in your code, but I removed it as well as the arraystrech-command, as I don't really see the need for it in this code. Feel free to add them in if you really want, but as I said, I don't think it really adds to the look or feel of it.

EDIT: As suggested by Mico, I added some distance between the sub-groups, do give them further distinction, using \addlinespace. Thanks Mico.

\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
{
\begin{tabular}{lll}
\toprule
Items & Type & Description\\
\midrule
Output & Integrated Application & ABC\\
& Process \& Element Definition & AVB\\
& Tasks & PWS\\
& S & X Queries\\
& Scripting Languages & Java Script or VB Script\\
& Message Start Events & Receive or reply events\\
\addlinespace Software & GUI tools & IBP\\
People & Designers & IDP\\
& Developers & PER\\
\addlinespace Technique & AAD&\\
& Integration & ERCFT\\
& Task & ETY\\
\bottomrule
\end{tabular}
}
\caption{TYURGY}
\label{t1}
\end{table}
\end{document}

Booktabs

Below is another solution, which I have modified less, and is more true to your original code and look.

You asked for a solution without multirow, but without giving a reason as to what was wrong with the output. In case there simply was a problem with the code, here is an attempt with multirow.

\documentclass{article}
\usepackage{graphicx}
\usepackage{multirow}
\begin{document}
\begin{table}
\renewcommand{\arraystretch}{1.2}
\centering
\setlength\tabcolsep{0.5em}
\scalebox{0.84}
{
\begin{tabular}{|l|l|l|}
\hline
Items & Type & Description\\
\hline
\multirow{6}{*}{Output} & Integrated Application & ABC\\
\cline{2-3}
& Process \& Element Definition & AVB\\
\cline{2-3}
& Tasks & PWS\\
\cline{2-3}
& S & X Queries\\
\cline{2-3}
& Scripting Languages & Java Script or VB Script\\
\cline{2-3}
& Message Start Events & Receive or reply events\\
\hline 
Software & GUI tools & IBP\\
\hline
\multirow{2}{*}{People} & Designers & IDP\\
\cline{2-3}
& Developers & PER\\
\hline
\multirow{3}{*}{Technique} & AAD&\\
\cline{2-3}
& Integration & ERCFT\\
\cline{2-3}
& Task & ETY\\
\hline
\end{tabular}
}
\caption{TYURGY}
\label{t1}
\end{table}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .