1

Hi guys I have this really weird table I made in word and want to make it in LaTeX since I am a noob in LaTeX I dont know how to split a column into several rows can some please tell me the coding how to do that I am attaching a picture of what I want enter image description here

I can make the first row but I down know how to split the second row into red green and blue rows


UPDATE

guys this is the code I am using

\begin{table}
\begin{tabular}{ | 
  >{\centering\arraybackslash} p{5cm} 
   | >{\centering\arraybackslash}p{2cm} 
   | >{\centering\arraybackslash}p{2cm} 
   | >{\centering\arraybackslash}p{2cm} 
   | >{\centering\arraybackslash}p{2cm} |} \hline
\bfseries{Oil Concentration} & \bfseries{Colour} & \bfseries{Oil} & \bfseries{Water} & \bfseries{Rock}\\ \hline
\multirow{3}{*}{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\ \hline
& Green & 72 & 112 & 14 \\ \hline
& Blue & 58 & 105 & 13 \\ \hline

\end{tabular}
\end{table}

However now I have a new issue how do I remove the horizontal line in the first column between N-Decane + Oil Red O ???

enter image description here

  • a search for "multirow" mighthelp – Bort Jul 24 '15 at 14:59
  • @Bort there is no multirow here, just \cline{2-5} – touhami Jul 24 '15 at 15:07
  • @touhami okay fair point, but I think I would be better to use a multirow (or at least use the "green" line) – Bort Jul 24 '15 at 15:09
  • There might be \multirow s in the first column, if you want a smaller vertical spacing between the lines. – Bernard Jul 24 '15 at 15:18
  • guys this is the code I am using its updated in the question above – Bakhtawar Khattak Jul 24 '15 at 15:23
2

Here are two solutions, with vertical lines, and without, more ‘professional’ (requires the booktabs package). In both cases, I use the makecell package, that allows for a common formatting and line breaks is column and row heads, and cellspace for some vertical padding.

    \documentclass[a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{array, booktabs, multirow, makecell, cellspace} %
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{5pt}
\renewcommand\theadfont{\bfseries}
\usepackage{eqparbox}
    \begin{document}

\begin{table}
  \begin{tabular}{ |
      >{\centering\arraybackslash} p{5cm}
      | >{\centering\begin{eqminipage}[l]{COL}}p{2cm}<{\end{eqminipage}}
      | >{\centering\arraybackslash}S{p{2cm}}
      | >{\centering\arraybackslash}p{2cm}
      | >{\centering\arraybackslash}p{2cm} |} \hline
      \thead{Oil Concentration} & \thead{\makebox[0pt]{Colour}} & \thead{Oil} & \thead{Water} & \thead{Rock} \\
      \hline
      \multirowthead{3}[-1ex]{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\\cline{2-5}
                                                    & Green & 72 & 112 & 14 \\ \cline{2-5}
                                                    & Blue & 58 & 105 & 13 \\
      \hline
      \multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Pentanoic Acid} & Red & 155 & 137 & 15 \\
      \cline{2-5}
                                                    & Green & 114 & 164 & 11 \\ \cline{2-5}
                                                    & Blue & 110 & 125 & 1 \\
      \hline
      \multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Butyric Acid} & Red & 180 & 179 & 24 \\
      \cline{2-5}
                                                    & Green & 164 & 209 & 20 \\ \cline{2-5}
                                                    & Blue & 143 & 177 & 13 \\
      \hline
      \multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Carboxylic Acid} & Red & 162 & 136 & 17 \\
      \cline{2-5}
                                                    & Green & 121 & 119 & 7 \\
      \cline{2-5}
                                                    & Blue & 95 & 107 & 0 \\
      \hline
    \end{tabular}
  \end{table}

  \begin{table}
    \begin{tabular}{@{} %
        >{\centering\arraybackslash} p{5cm}
        >{\centering\begin{eqminipage}[l]{COL}}p{2cm}<{\end{eqminipage}}
        >{\centering\arraybackslash}S{p{2cm}}
        >{\centering\arraybackslash}p{2cm}
        >{\centering\arraybackslash}p{2cm}@{}}
        \toprule
        \thead{Oil Concentration} & \thead{\makebox[0pt]{Colour}} & \thead{Oil} & \thead{Water} & \thead{Rock} \\
        \cmidrule(lr){1-5}
        \multirowthead{3}[-1ex]{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\
                                                      & Green & 72 & 112 & 14 \\
                                                      & Blue & 58 & 105 & 13 \\
        \addlinespace
        \multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Pentanoic Acid} & Red & 155 & 137 & 15 \\
                                                      & Green & 114 & 164 & 11 \\
                                                      & Blue & 110 & 125 & 1 \\
        \addlinespace
        \multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Butyric Acid} & Red & 180 & 179 & 24 \\
                                                      & Green & 164 & 209 & 20 \\
                                                      & Blue & 143 & 177 & 13 \\
        \addlinespace
        \multirowthead{3}{N-Decane + Oil Red O & & & & \\ $ + {}$ Cyclo Hexane\\ Carboxylic Acid} & Red & 162 & 136 & 17 \\
                                                      & Green & 121 & 119 & 7 \\
                                                      & Blue & 95 & 107 & 0 \\
        \bottomrule
      \end{tabular}
    \end{table}

\end{document} 

enter image description here

0

Presented here is one possible way:

\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}

\begin{tabular}{|c|c|c|c|c|}
\hline
Oil Concentration & Colour & Oil & Water & Rock \\
\hline
\multirow{3}{*}{N-Decane + Oil Red O} & Red & 88 & 109 & 24 \\ \cline{2-5}
& Green & 72 & 112 & 14 \\ \cline{2-5}
& Blue & 58 & 105 & 13 \\ \cline{2-5}
\hline
\multirow{3}{*}{\parbox{4cm}{N-Decane + Oil Red O  + Cyclo Hexane  Pentanoic Acid}} & Red & 153 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\ \cline{2-5}
\hline
\multirow{3}{*}{\parbox{4cm}{N-Decane + Oil Red O + Cyclo Hexane  Pentanoic Acid}} & Red & 153 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\ \cline{2-5}
\hline
\multirow{3}{*}{\parbox{4cm}{N-Decane + Oil Red O + Cyclo Hexane Pentanoic Acid}} & Red & 153 & 137 & 15 \\
\cline{2-5}
& Green & 114 & 164 & 11 \\ \cline{2-5}
& Blue & 110 & 125 & 1 \\ \cline{2-5}
\hline 
\end{tabular}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.