1

I want to create a table with \multirow and \multicolumn in LaTeX.

I tried some post 1, 2, 3 to create my table but because I wasn't able to create my table.

Please help me with LaTeX code for the table given below.


enter image description here

I wrote this code so far:

\begin{tabular}{ |p{5cm}|p{4cm}|p{3cm}|p{3cm}| } 
\hline 
\multicolumn{4}{|c|}{\textbf{Crop field location info}} \\ 
\hline 
\textbf{District name} & \textbf{Tehsil name} & \textbf{UC name} 
  & \textbf{UC \#}\\ & & &\\ 
\hline  
\multicolumn{4}{|c|}{\textbf{Farmer's info}} \\ 
\hline 
\textbf{Farmer name} & \textbf{Farmer contact \#}
  & \multicolumn{2}{ |c| }{\textbf{Farmer's land holding (acres)}} \\ 
& & \multicolumn{2}{ |c| }{} \\ 
\hline 
\textbf{Item} & \textbf{Unit} & \textbf{Rate/Unit} & \textbf{Total Cost}\\
\hline 
\end{tabular} 
5
  • 1
    Please tell us what you've tried so far, LaTeX-wise. Please also tell us more about the document class, the font, the font size, and the width and height of the text block that are in use in your document.
    – Mico
    Commented Jun 23, 2015 at 6:32
  • 1
    In your tabular there is no multirow, just multicolumn
    – touhami
    Commented Jun 23, 2015 at 7:02
  • @Mico I wrote this code so far; \begin{tabular}{ |p{5cm}|p{4cm}|p{3cm}|p{3cm}| } \hline \multicolumn{4}{|c|}{\textbf{Crop field location info}} \\ \hline \textbf{District name} & \textbf{Tehsil name} & \textbf{UC name} & \textbf{UC \#}\\ & & &\\ \hline \multicolumn{4}{|c|}{\textbf{Farmer's info}} \\ \hline \textbf{Farmer name} & \textbf{Farmer contact \#} & \multicolumn{2}{ |c| }{\textbf{Farmer's land holding (acres)}} \\ & & \multicolumn{2}{ |c| }{} \\ \hline \textbf{Item} & \textbf{Unit} & \textbf{Rate/Unit} & \textbf{Total Cost}\\ \hline \end{tabular}
    – cst
    Commented Jun 23, 2015 at 8:22
  • But I don't know that what to do for column separtion for Unit -- Quantity and Rate/Unit -- All Cost.
    – cst
    Commented Jun 23, 2015 at 8:24
  • 2
    I have edited you code in the comment into the question. It is better to add code there because it is easier to preserve linebreaks etc. Commented Jun 23, 2015 at 8:33

2 Answers 2

1

Your effort for prepare MWE is to minimal :_), so I down wrote from your image only beginning of table. For your table you don't need multirow cells. An simple solution is as follows:

\documentclass{article}

%just for show only a table
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tabular}
    \setlength\PreviewBorder{1em}


    \begin{document}
    \sffamily
    \small
    \renewcommand{\arraystretch}{1.2}
\begin{tabular}{|p{0.4\textwidth}   % determine column width to your wish
                |p{0.1\textwidth}
                |p{0.15\textwidth}
                |p{0.15\textwidth}
                |p{0.20\textwidth}|
                }
    \hline
\multicolumn{5}{|c|}{Crop field location info}\\
    \hline
District name & 
    \multicolumn{2}{|c|}{Tehsil name} 
                    & UC name   & UC \#                     \\[2em]
    \hline
\multicolumn{5}{|c|}{Farmer's info}                         \\
    \hline
Farmer name &
    \multicolumn{2}{|c|}{Farmer contract \#} 
                    & 
    \multicolumn{2}{|c|}{Farmer's Land holdings (acres)}    \\[2em]
    \hline
Item        & Unit  & Quality   & Rate/Unit & All cost      \\
    \hline
% repeat regarding to your table contents ...   
\multicolumn{1}{|c}{}
            &
    \multicolumn{4}{ c|}{Land preparation cost}             \\
    \hline
Ploughing \& planking (Bullocks)       
            & Rs./Hr  &         &           &               \\
    \hline
etc         &         &         &           &               \\
    \hline
\end{tabular}
    \end{document}

enter image description here

1

You could use the \multicol package for this task. Here I have an example of the first few rows:

\documentclass{article}
\usepackage{multicol}

\begin{document}

\begin{tabular}{ |p{5cm}|p{2cm}|p{2cm}|p{3cm}|p{3cm}| } 
\hline 
\multicolumn{5}{|c|}{\textbf{Crop field location info}} \\ 
\hline 
\textbf{District name} & \multicolumn{2}{ |c| }{\textbf{Tehsil name}} 
    & \textbf{UC name} & \textbf{UC \#}\\ 
& \multicolumn{2}{ |c| }{} & &\\ 
\hline 
\multicolumn{5}{|c|}{\textbf{Farmer's info}} \\
\hline 
\textbf{Farmer name} & \multicolumn{2}{|c|}{\textbf{Farmer contact \#}} 
    & \multicolumn{2}{ |c| }{\textbf{Farmer's land holding (acres)}} \\
& \multicolumn{2}{ |c| }{} & \multicolumn{2}{ |c| }{} \\ 
\hline 
\textbf{Item} & \textbf{Unit} & \textbf{Quantity} & \textbf{Rate/Unit} & \textbf{Total Cost}\\ 
\hline 
& \multicolumn{4}{ c| }{\textbf{Land preparation cost}} \\
\hline
Ploughing \& planking (Bullocks) & Rs./hr & & & \\
\hline
Leveling (Bullocks) & Rs./hr & & & \\
\hline
\end{tabular}

\end{document}

More information on the correct usage can be found at latex_tables

4
  • there is no need to multicol package
    – touhami
    Commented Jun 23, 2015 at 7:03
  • @lenxn I wrote the below code so far but I don't know what to do for column division for below the 'Farmer contact #' and 'Farmer's Land holding (coloumns)'. The code is in the next comment.
    – cst
    Commented Jun 23, 2015 at 8:21
  • \begin{tabular}{ |p{5cm}|p{4cm}|p{3cm}|p{3cm}| } \hline \multicolumn{4}{|c|}{\textbf{Crop field location info}} \\ \hline \textbf{District name} & \textbf{Tehsil name} & \textbf{UC name} & \textbf{UC \#}\\ & & &\\ \hline \multicolumn{4}{|c|}{\textbf{Farmer's info}} \\ \hline \textbf{Farmer name} & \textbf{Farmer contact \#} & \multicolumn{2}{ |c| }{\textbf{Farmer's land holding (acres)}} \\ & & \multicolumn{2}{ |c| }{} \\ \hline \textbf{Item} & \textbf{Unit} & \textbf{Rate/Unit} & \textbf{Total Cost}\\ \hline \end{tabular}
    – cst
    Commented Jun 23, 2015 at 8:21
  • I just noticed, that most of the table has five columns, so i think the best way to go is to use a tabular with initially five columns. I have updated my code example accordingly.
    – lenxn
    Commented Jun 23, 2015 at 9:05

You must log in to answer this question.

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