Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am inserting two graphs (of different size) in the following way:

\begin{figure}[H]
\begin{center}
\includegraphics[scale=0.5]{graph1.eps}
\includegraphics[scale=0.3]{graph2.eps}
\caption{\label{fig:scaled_diss}}
\end{center}
\end{figure}

which would be perfect if the graphs were of near-identical build, but it's currently resulting in the graph borders being mis-aligned, as in:

enter image description here

So the right graph doesn't have tics on the x axis. How do I make it that the graphs are aligned at the top, then the scaling can be altered, to give something like this:

enter image description here

share|improve this question
1  
don't use scale= use height= so they both scale to the same height. (and don't use H :-) –  David Carlisle Mar 10 '13 at 21:41
    
@David But using "height=" won't give the desired result -- in the desired result, the two images do not have the same height, because of the x-axis labels in the first image. (And for examples like the way the figures and text are used together seamlessly in the question itself, H is a reasonable way to ensure the result isn't nonsense, if you need to use the figure command at all. :-) –  Matt Jan 18 at 10:55

3 Answers 3

up vote 23 down vote accepted

Use the adjustbox package's valign=t key to align the graphics contents at the top:

enter image description here

\documentclass{article}
\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox
\begin{document}
\begin{figure}
  \centering
  \includegraphics[scale=0.5,valign=t]{example-image-a}
  \includegraphics[scale=0.3,valign=t]{example-image-b}
  \caption{A caption\label{fig:scaled_diss}}
\end{figure}
\end{document}

Using the export key with adjustbox, this will load the graphicx package, and allow you to use its keys as part of \includegraphics.

Also, for your specific example, it may be more advisable to use a fixed height, rather than a scale. This way you can more readily provide the same vertical alignment of your items (graphics or otherwise).

share|improve this answer

Since adjustbox is not easy to install on ubuntu-12.04 the solution proposed in Aligning image and text on top, with minipages can be useful.

\begin{tabular}{p{0.5\textwidth} p{0.5\textwidth}}
  \vspace{0pt} \includegraphics[width=0.49\textwidth]{example-image-a} &
  \vspace{0pt} \includegraphics[width=0.49\textwidth]{example-image-b}
\end{tabular}
share|improve this answer

A third alternative is the stackengine package, with its \belowbaseline command, which places the top of an object a given distance below the baseline, shown below without, then with \belowbaseline.

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\begin{document}

\def\figa{\rule{1in}{1in}}
\def\figb{\scalebox{.6}{\figa}}

\begin{figure}[H]
\begin{center}
\figa~\figb
\caption{\label{fig:scaled_diss}}
\end{center}
\end{figure}

\begin{figure}[H]
\begin{center}
\belowbaseline[0pt]{\figa}~\belowbaseline[0pt]{\figb}
\caption{\label{fig:scaled_diss}}
\end{center}
\end{figure}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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