2

I'm new with latex and trying to do a table with multirow. Almost got it but now my image its outside of the table ¿How can I adjust the height of my table in such way that my image stays inside?

This is my code:

\documentclass[letterpaper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{array}

\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{multirow}

\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}
\setlength{\parindent}{0.95cm}
\pagestyle{fancy}
\usepackage{graphicx}

\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
\begin{tabular}{|m{3.0cm}|m{8.0cm}|m{2.5cm}|m{3.0cm}|}
            \hline 
            \multirow{2}{3cm}{\centering \includegraphics[scale=0.04]{escudounipamplona.png} }
            & 
            \multirow{2}{8cm}{\centering Propuesta trabajo de grado para optar por el título de Ingeniero en Mecatrónica}
            & 
            Test1
            & 
            Test2  
            \\
            \cline{3-4}
            &&
            Test3 
            &
            Test4\\
            \hline
            \end{tabular}          
}

\begin{document}
\chapter{Chapter title}

%% add this if you want the fancy style also on the first page of a chapter:
\thispagestyle{fancy}
\section{Section title}
\end{document}

And this is my output:

enter image description here

Edit: This is the desired layout, I want equally spaced rows:

I want equally spaced rows

4
  • Leave 3 empty rows above and 3 rows below ( by adding &&&\\ )and change \multirow{2} to \multirow{8} in both places.
    – user11232
    Feb 3, 2015 at 1:35
  • 1
    How should the other elements align with respect to the image? Can you show an image showing the desired layout? Feb 3, 2015 at 1:39
  • @GonzaloMedina Im gonna edit my post with the desired layout.
    – Juan David
    Feb 3, 2015 at 1:52
  • Use \includegraphics[height=2\normalbaselineskip]{<image>}.
    – Werner
    Feb 3, 2015 at 2:01

2 Answers 2

1

Change arraystretch and control the image size using height and/or width keys:

\documentclass[letterpaper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{fancyhdr}
\usepackage{multirow}
\usepackage[hmargin=2cm,top=4cm,headheight=65pt,footskip=65pt]{geometry}
\usepackage[demo]{graphicx}

\setlength{\parindent}{0.95cm}

\pagestyle{fancy}

\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
\begingroup
\renewcommand\arraystretch{1.5}
\begin{tabular}{|>{}m{3.0cm}|m{8cm}|m{2.4cm}|m{2.4cm}|}
            \hline
            \multirow{2}{3cm}{\centering\raisebox{-12pt}{\includegraphics[height=40pt,width=20pt]{escudounipamplona.png}}}
            & 
            \multirow{2}{8cm}{\centering Propuesta trabajo de grado para optar por el título de Ingeniero en Mecatrónica}
            & 
            Test1
            & 
            Test2  
            \\
            \cline{3-4}
            &&
            Test3 
            &
            Test4\\
            \hline
            \end{tabular}%
\endgroup          
}

\begin{document}
\chapter{Chapter title}

%% add this if you want the fancy style also on the first page of a chapter:
\thispagestyle{fancy}
\section{Section title}

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

2
  • Don Gonzalo, muchas gracias. No entiendo muy bien lo que hizo pero funciono a la perfeccion. Gracias
    – Juan David
    Feb 3, 2015 at 2:30
  • 1
    @jd1215 ¡De nada! \arraystretch (default value=1) is a factor controlling the row height in a tabular which is calculated as \arraystretch times the height of a \strutbox. Redefining this factor allows you to increase (if the factor is set to a value greater than one) or to decrease (if the factor is set to a value less than one) the default row height. Feb 3, 2015 at 2:35
2

Here's one way:

\documentclass[letterpaper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{array,tabularx}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\renewcommand{\tabularxcolumn}[1]{M{#1}}

\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{multirow}

\usepackage[hmargin=2cm,top=4cm,headheight=75pt,footskip=65pt]{geometry}
\setlength{\parindent}{0.95cm}
\pagestyle{fancy}
\usepackage{graphicx}

\renewcommand{\headrulewidth}{0pt}
\fancyhead[CE,CO,LE,LO,RE,RO]{} %% clear out all headers
\fancyhead[C]{%
  \begin{tabularx}{\textwidth}{|M{3.0cm}|X|M{2.5cm}|M{3cm}|}
    \hline
    \multirow{4}*{\includegraphics[scale=0.075]{tiger}}
    &
    \multirow{4}*{\parbox{\linewidth}{\centering Propuesta trabajo de grado para optar por el título de Ingeniero en Mecatrónica}}
    &
    \multirow{2}*{Test 1}
    &
    \multirow{2}*{Test 3}\\
    &&&
    \\\cline{3-4}
    &&
    \multirow{2}*{Test 2}
    &
    \multirow{2}*{Test 4}\\
    &&&\\
    \hline
  \end{tabularx}
}

\begin{document}
  \chapter{Chapter title}

  %% add this if you want the fancy style also on the first page of a chapter:
  \thispagestyle{fancy}
  \section{Section title}
\end{document}

Tiger header

You must log in to answer this question.

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