1

The two figures have been exported from matlab and they have the same size: 560 * 315. They are in vector graphics format .eps. The problem is that the two figures are not aligned vertically, as shown in the following image: enter image description here

The code is the following:

\documentclass[12pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{float}
\usepackage{caption}

\title{figures}

\begin{document}

\begin{figure}[H] 
\centering
\includegraphics[scale=1]{es5_vel_ang.eps}
\caption{Componenti $p(t)$, $q(t)$ ed $r(t)$ della velocità angolare.}
\label{fig:es5_vel_ang}
\vspace{4mm}
\end{figure} 

\begin{figure}[H] 
\centering
\includegraphics[scale=1]{es5_linear_vel.eps}
\caption{Componenti $u$, $v$, $w$ della velocità del baricentro.}
\label{fig:es5_vel_lin}
\vspace{4mm}
\end{figure} 

\end{document}

The image files: Two .eps images

Edit. I found and additional problem: the number 100 (on both horizontal axes) seems to be cut on its right side. Any suggestion to solve it? enter image description here

2
  • Since these are external pictures, with differrent left margins (according to the figures), I suggest that you crop them correctly to let exactly the same blank space on the left, before including them in your document. On the other hand, you can add some \hspace to the first one and play with the units.
    – SebGlav
    Apr 7, 2021 at 10:30
  • 2
    probably due to the size of the numbers on the left axis the actual graphs are not positioned in the same way, tex has no knowledge of the internal structure of the eps. It centres the images as provided Apr 7, 2021 at 10:31

1 Answer 1

0

The numbers on the y axis make the difference: 160 is wider than 2. TeX has absolutely no idea where the borders or the labels are: in its eyes the pictures are just boxes.

Workaround: since the x axis is the same in both graphs, you can put the first picture in a right-aligned box as wide as the second (wider) picture.

\documentclass[12pt,twoside]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\sbox0{\includegraphics{es5_linear_vel}}% the wider of the two
\makebox[\wd0][r]{\includegraphics{es5_vel_ang}}%
\caption{Componenti $p(t)$, $q(t)$ ed $r(t)$ della velocità angolare.}
\label{fig:es5_vel_ang}
\vspace{5ex}
\usebox0%
\caption{Componenti $u$, $v$, $w$ della velocità del baricentro.}
\label{fig:es5_vel_lin}
\end{figure} 

\end{document}

enter image description here

7
  • Thanks for your solution. I noticed another problem: the number 100 seems to be cut on its right side (both in my code and in your). Any suggestion to solve it? P.s. I've added this problem to the original question.
    – g_don
    Apr 7, 2021 at 10:53
  • @Giuseppe The number is cut in the snapshot because I took it as close as possible to the vertical line of the border. It is of course not cut in the real PDF.
    – campa
    Apr 7, 2021 at 10:55
  • it is cut also in the exported pdf and in my original screenshots.
    – g_don
    Apr 7, 2021 at 10:57
  • @Giuseppe Oh, I see what you mean. That's not a TeX problem though, I guess the eps has a too tight bounding box. Can't matlab export directly in pdf?
    – campa
    Apr 7, 2021 at 11:06
  • I try to export in pdf but I should cut the image before importing in overleaf. However it seems that in your snapshots there is not the problem! How is it possible if the code is the same?
    – g_don
    Apr 7, 2021 at 11:11

You must log in to answer this question.

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