2

How can I change the height of the minipage in the figure envirment? Since I tried it so \includegraphics[width=.6, height=0.8\linewidth]{img/moovit_4} and I got this error ! Illegal unit of measure (pt inserted). How can I put code here? it is not like stackoverflow, I can not see the icon right to the image icon in the header. I used these quotation marks``

\begin{figure}[H]
\centering
\begin{minipage}{.5\textwidth}
  \centering
  \includegraphics[width=.5\linewidth]{img/moovit_2}
  \captionof{figure}{A figure}
  \label{fig:test1}
\end{minipage}%
\begin{minipage}{.5\textwidth}
  \centering
  \includegraphics[width=.6, height=.8\linewidth]{img/moovit_4}
  \captionof{figure}{Another figure}
  \label{fig:test2}
\end{minipage}
\end{figure}
2
  • 2
    You have to pass a unity to .6. For example .6\linewidth or 3cm. – Sigur Jan 25 '15 at 23:57
  • 4
    also don't use both width and height or you will distort the figure, and did you intend ` height=.8\linewidth` ie setting the height of the image based on the available width? – David Carlisle Jan 26 '15 at 0:03
4

As @sigur has already pointed out in a comment, you need to adjust the way you specify the width of the second image. You may also want to align the minipages in a way that both captions are at the same level; this can be done, e.g., by setting the location specifier [b] for the two minipage environments.

A separate comment: Since the two minipages occur inside a float of type figure, it's not necessary to write \captionof{figure}{...}; the simpler \caption{...} will do too. Finally, the first \centering statement (right after \begin{figure}[H]) is redundant since the two minipages occupy the full width of the textblock -- nothing there to center, really.

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real document
\usepackage{caption} 
\usepackage{float}   % for "H" location specifier
\begin{document}
\begin{figure}[H]
%%\centering  %% redundant
\begin{minipage}[b]{.5\textwidth}
  \centering
  \includegraphics[width=.5\linewidth]{img/moovit_2}
  \caption{A figure}
  \label{fig:test1}
\end{minipage}%
\begin{minipage}[b]{.5\textwidth}
  \centering
  \includegraphics[width=.6\linewidth, height=.8\linewidth]{img/moovit_4}
  \caption{Another figure}
  \label{fig:test2}
\end{minipage}
\end{figure}
\end{document}

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.