1

I know this is a simple question but I couldn't figure it out using the forum so here it is :

I am trying to align vertically both an eps figure and a tikzpicture situated on the same page : for some reason even while using centering it still appears shifted a little bit. I've also tried the suggestion of this post How to vertically align two figures but it was unsuccessful.

enter image description here

I add this non executable code for illustration only since I don't think it's relevant to put a complete MWE because I used a long tikz script to generate the figure so I show only this part :

\begin{document}

%%%%FIGURE VARIATION DE A%%%%%
\begin{figure}[h]
\centering
\includegraphics[width = .6\textwidth]{images/Chapitre4/variationa.eps}
\caption{Tracé des profils de hauteur $h(x,t)$ à différents instants pendant la coalescence. Nous notons que la pente $\alpha$ du front des gouttes varie au cours du temps : une pente constante n'est valable qu'à des temps très courts au moment de la coalescence.}
\label{variationa}
\end{figure}

%% TEXT%%
\lipsum[1]

%%%FIGURE HYPERBOLOIDE%%%%%
\begin{figure}[h]
\centering
\begin{tikzpicture}[scale=1.2,el/.style args={#1,#2}{draw,ellipse,minimum width=#1, minimum height=#2},outer sep=0pt,>=latex']
...
\end{tikzpicture}
\caption{Illustration d'une forme hyperboloïde de section transverse correspondant à une ellipse dont le demi-axe vertical est la hauteur mesurée au point de coalescence $h_0(t)$.}
\label{hyperboloide}
\end{figure}
\end{document}

Of course, you can correct me in the comment if it is necessary to put all the details of the code. Also, feel free to direct me to other similar posts that you may know that can help with this issue in case it has already been treated.

In advance, thank you for your help and your time,

Sincerely.

As suggested : the preview with fbox gives :

enter image description here

6
  • 2
    If you add \fbox{..} around the tikzpicture you will see what TeX thinks the bounding box is. Quite likely there's white space at either end, larger on the right.
    – egreg
    Commented Apr 28 at 15:39
  • I have added the preview in my post : it doesn't seem to have anormal space, does it ?
    – Waxler
    Commented Apr 28 at 17:46
  • 2
    The bounding box appears to be centered to me. Also, pgfplots adds extra white space to the left, so both are probably centered w.r.t their bounding boxes. Now if you want to align specifuc points, one can offset the bounding boxes acoodingly. See tex.stackexchange.com/questions/454434/… for example. Commented Apr 28 at 18:58
  • 1
    @Waxler It’s an optical effect, then, and you’ll see it with \fbox around both pictures..
    – egreg
    Commented Apr 28 at 19:25
  • @JohnKormylo : Thank you for your comments : I will look for the solution provided in this post as it seems to be close to what I want to achieve.
    – Waxler
    Commented Apr 29 at 10:25

1 Answer 1

1

As the fbox reveals, the diagram is being centred and it is only that the label $\Epsilon(h_0,a)$ is included in the bounding box such that the cylindrical object in the diagram (which is probably what your eye uses as a reference to compare alignment) appears off-set.

A neat approach I would take in this case would be to enclose the $\Epsilon(h_0,a)$ text, which is presumably in a node, inside an rlap as such:

\node[anchor=west] at (X,Y) {\rlap{$\Epsilon(h_0,a)$}};

Then the node text is printed but takes up no space, so the diagram will be (aesthetically) more aligned. Note anchor=west means the node text is printed to the right of the coordinate (X,Y) above.

You must log in to answer this question.

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