2

I am wondering did I use the right code, because the plots are not placed right in the Latex. Any better idea?

\documentclass[12pt]{report}
\usepackage{graphicx}
\begin{document}

\begin{figure}[ht!]
  \centering
\begin{minipage}[b]{0.4\textwidth}
\includegraphics[width=4.0in, height=2.7in] {temp.png}
\caption{Plot of hourly temperature from 2012-01-01 00:00 to 2016-06-13 23:00.} 
\end{minipage}
\hfill
\begin{minipage}[b]{0.4\textwidth}
  \includegraphics[width=2.7in, height=2.7in]{LRtemp.png}
 \caption{Linear relationship between demand and temperature}
\end{minipage}
\end{figure}

\end{document}

enter image description here

  • They seem to be aligned on the baseline as you requested. What did you want to happen instead? – cfr Aug 27 '16 at 15:30
  • @cfr: What is aligned? – Bernard Aug 27 '16 at 15:34
  • @cfr I would like both plots and the baseline to be alined, not just baseline. – Jeannie Aug 27 '16 at 15:34
  • Try to replace \begin{minipage}[b]{0.4\textwidth} with \begin{minipage}[t]{0.4\textwidth}. – Zarko Aug 27 '16 at 15:55
  • 1
    You can't have both as originally configured because the caption for one is one line longer than for the other. So if they are aligned on the baseline, the plots won't be, whereas if the plots are, the baselines won't be. – cfr Aug 27 '16 at 19:22
4

Some comments and observations, in no particular order:

  • The instruction \centering has no effect as the two minipage environments are separated by \hfill. Just omit \centering.

  • It may be more straightforward to set the widths of the two minipages to an absolute size, say, 4in and 2.7in, respectively, and then set the widths of the graphics to \linewidth.

  • A side-benefit of assigning absolute widths to the minipages and relative widths to the included graphics is that the widths of the captions and graphics will coincide -- something that's decidedly not the case in the screenshot you posted.

enter image description here

\documentclass[12pt]{report}
\usepackage[demo]{graphicx} % remove 'demo' option in real document
\usepackage[margin=.5in,letterpaper]{geometry} % set page block parameters
\begin{document}
\setcounter{chapter}{2} % just for this example...
\setcounter{figure}{10}

\begin{figure}[ht!]
\begin{minipage}[b]{4in}
    \includegraphics[width=\linewidth, height=2.7in] {temp.png}
    \caption{Plot of hourly temperature from 2012-01-01 00:00 to 2016-06-13 23:00} 
\end{minipage}
\hfill
\begin{minipage}[b]{2.7in}
    \includegraphics[width=\linewidth, height=2.7in]{LRtemp.png}
    \caption{Linear relationship between demand and temperature}
\end{minipage}
\end{figure}
\end{document}
|improve this answer|||||

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.