# Aligning two pictures without subcaptions to the top with the subcaption package

My problem is similar to this one:

Align by the top borders of figures when using subcaption

I want to align two pictures to the top. The solution given works fine for pictures with subcaptions. But my pictures should not have a subcaption, the two pictures shall only have one caption. So if I remove the subcaptions the pictures are not align to the top.

MWE:

documentclass[a4paper,11pt]{article}
\usepackage{subcaption}
\usepackage{tikz,pgf,pgfplots}
\usetikzlibrary{plotmarks,shapes,positioning,fit}
\pgfkeys{/pgf/number format/.cd ,use comma ,set thousands separator={.}}
\usetikzlibrary{calc}
\usetikzlibrary{spy}
\usepgfplotslibrary{external}
\pgfkeys{/pgf/images/include external/.code=\includegraphics{#1}}
\tikzexternalize[prefix=tikzpdf/]% activate with a name prefix
\usepackage{filemod}
\newcommand{\includetikz}[2]{
\tikzsetnextfilename{#2}
\filemodCmp{tikzpictures/#1/#2.tex}{tikzpdf/#2.pdf}
{\tikzset{external/remake next}}{}
\input{tikzpictures/#1/#2.tex}
}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[t]{0.35\textwidth}
\centering
%\caption{}
\includegraphics[width=\textwidth]{ort_unten}
\label{fig:skizze_ort_unten}
\end{subfigure}
\begin{subfigure}[t]{0.55\textwidth}
\centering
%\caption{}
\setlength{\fwidth}{\textwidth}
\setlength{\fheight}{7cm}
\includetikz{ort}{ort_unten}
\end{subfigure}
\caption{one picture (left) and a graph (right)}
\label{fig:ort_unten}
\end{figure}
\end{document}


This is the result:

Is there a possibility to fix this?

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Feb 28 '14 at 18:25

Since I don't have the pictures you mention, I'm using some provided by mwe. Since I'm unfamiliar with the inclusion-tactics of tikz, I can only speculate whether this will work/not:

\documentclass{article}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[t]{0.35\textwidth}
\centering
%\caption{}
\includegraphics[width=\linewidth,valign=t]{example-image-a}
\label{fig:skizze_ort_unten}
\end{subfigure}
\begin{subfigure}[t]{0.55\textwidth}
\centering
%\caption{}
\includegraphics[width=\linewidth,height=7cm,valign=t]{example-image-b}
\end{subfigure}
\caption{one picture (left) and a graph (right)}
\label{fig:ort_unten}
\end{figure}
\end{document}


The idea is to use adjustbox with the export option. This adds adjustbox options to those provided by graphicx allowing you to set the vertical alignment for each image. I've chosen them both to align at the top.

-
Thank you for your answer. I think your solution will probably work. But for me it is easier to use my own command \includetikz and I do not know where to put the valign command in it. So for me it is easier to use the \vspace*{0pt} trick. But thanks anyway! –  user47091 Feb 28 '14 at 18:57
@user47091: You will most likely use \pgfkeys{/pgf/images/include external/.code=\includegraphics[valign=t]{#1}}. –  Werner Feb 28 '14 at 19:01
Ah yes you are right. Thanks. –  user47091 Feb 28 '14 at 19:07

Since subfigures are minipages, the following trick works: add \vspace*{0pt} just after each \begin{subfigure}.

MWE (I've used images from the mwe package since I don't have yours)

\documentclass[a4paper,11pt]{article}
\usepackage{subcaption}
\usepackage{tikz,pgf,pgfplots}
\usetikzlibrary{plotmarks,shapes,positioning,fit}
\pgfkeys{/pgf/number format/.cd ,use comma ,set thousands separator={.}}
\usetikzlibrary{calc}
\usetikzlibrary{spy}
\usepgfplotslibrary{external}
\pgfkeys{/pgf/images/include external/.code=\includegraphics{#1}}
\tikzexternalize[prefix=tikzpdf/]% activate with a name prefix
\usepackage{filemod}
\newcommand{\includetikz}[2]{
\tikzsetnextfilename{#2}
\filemodCmp{tikzpictures/#1/#2.tex}{tikzpdf/#2.pdf}
{\tikzset{external/remake next}}{}
\input{tikzpictures/#1/#2.tex}
}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[t]{0.35\textwidth}
\vspace*{0pt}
\centering
%\caption{}
\includegraphics[width=\textwidth]{example-image-a}
\label{fig:skizze_ort_unten}
\end{subfigure}
\begin{subfigure}[t]{0.55\textwidth}
\vspace*{0pt}
\centering
%\caption{}
%\setlength{\fwidth}{\textwidth}
%\setlength{\fheight}{7cm}
\includegraphics[width=\textwidth]{example-image-b}
\end{subfigure}
\caption{one picture (left) and a graph (right)}
\label{fig:ort_unten}
\end{figure}
\end{document}


Output:

-
Great! Thank you it works fine. –  user47091 Feb 28 '14 at 18:52