10

I have two sublfoat that I would like to align from the horizontal coordinate line.

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{subfig}
\begin{document}
\begin{figure}
  \centering
  \subfloat[Using the electrode as einzel lens.]{
\begin{tikzpicture}
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, 0.75) node[above] {$V_{\text{ein}}$} -- ++(0.30, 0) -- ++(0.15, -0.750);
\end{tikzpicture}
}
\quad
  \subfloat[Using the electrode as repeller.]{
\begin{tikzpicture}
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, -.75) node[below] {$V_{\text{rep}}$} -- ++(0.30, 0) -- ++(0.15, 0.750);
\end{tikzpicture}
}
  \caption{Potentail diagram of the extraction.}
  \label{fig:potential}
\end{figure}
\end{document}

enter image description here

2
  • 2
    Fix spelling of "potential" in the caption before you submit the paper? Oct 2, 2013 at 14:13
  • The simplest solution is to change baseline to both pictures, e.g. append [baseline={(0,-1.3)}] to both tikzpicture environments. To a certain amount, it does not change the right picture but adds white space between the first one and its caption.
    – Celdor
    Oct 3, 2022 at 7:02

2 Answers 2

15

You can add the baseline option to both TikZ picture so that the vertical value y = 0 will be the baseline from both pictures. But this also displaces the captions, this can be avoided by adding a pseudo-node to the left picture where the right one has the V_rep node.

With the subcaption package, the same trick can be used.

Code (subfig)

\documentclass{article}
\usepackage{tikz,amsmath}
\usepackage{subfig}
\begin{document}
\begin{figure}\centering
\subfloat[Using the electrode as einzel lens.]{
\begin{tikzpicture}[baseline]
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, 0.75) node[above] {$V_{\text{ein}}$} -- ++(0.30, 0) -- ++(0.15, -0.750);
\end{tikzpicture}}\quad
\subfloat[Using the electrode as repeller.]{
\begin{tikzpicture}[baseline]
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, -.75) node[below] {$V_{\text{rep}}$} -- ++(0.30, 0) -- ++(0.15, 0.750);
\end{tikzpicture}}
\caption{Potentail diagram of the extraction.}
\end{figure}

\begin{figure}\centering
\subfloat[Using the electrode as einzel lens.]{
\begin{tikzpicture}
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, 0.75) node[above] {$V_{\text{ein}}$} -- ++(0.30, 0) -- ++(0.15, -0.750);
\path (0,-.75) node[below,opacity=0] {$V_{\text{rep}}$}; % <- Pseudonode
\end{tikzpicture}}\quad
\subfloat[Using the electrode as repeller.]{
\begin{tikzpicture}
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, -.75) node[below] {$V_{\text{rep}}$} -- ++(0.30, 0) -- ++(0.15, 0.750);
\end{tikzpicture}}
\caption{Potentail diagram of the extraction.}
\end{figure}
\end{document}

Code (subcaption)

\documentclass{article}
\usepackage{tikz,amsmath}
\usepackage{subcaption}
\begin{document}
\begin{figure}\centering
\subcaptionbox{Using the electrode as einzel lens.}{
\begin{tikzpicture}
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, 0.75) node[above] {$V_{\text{ein}}$} -- ++(0.30, 0) -- ++(0.15, -0.750);
\path (0,-.75) node[below,opacity=0] {$V_{\text{rep}}$}; % <- Pseudonode
\end{tikzpicture}}\quad
\subcaptionbox{Using the electrode as repeller.}{
\begin{tikzpicture}
\draw[->] (-0.25,0) -- (3.5,0) node[below left] {$z$};
\draw[->] (0,-0.25) -- (0,3.5) node[below left] {$V$};
\draw (0, 3.0) node[above right] {$V_p$} -- ++(0.35, 0) -- ++(1.25, -3.0) -- ++(0.25, 0) -- ++(0.15, -.75) node[below] {$V_{\text{rep}}$} -- ++(0.30, 0) -- ++(0.15, 0.750);
\end{tikzpicture}}
\caption{Potentail diagram of the extraction.}
\label{fig:potential}
\end{figure}
\end{document}

Output

enter image description here

1
0

I add a white (invisible) grid to the smaller image to increase its height:

\begin{tikzpicture}
    %Grid
    \draw[white] (x1,y1) grid (x2,y2);

    ---
\begin{tikzpicture}

You must log in to answer this question.

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