4

I need to move the left part of the subfigure in the following picture upward:

img1

That is, the image should like the following:

img2

so the subfigures are aligned vertically at the top.

Document:

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{graphicx}
\usepackage{tikz}                                   % graphics
\usetikzlibrary{shapes.geometric,calc,arrows,decorations.markings,decorations.pathmorphing}
\usepackage{pgfplots}
\usepackage{subfigure}

\begin{document}

\section {First}

text

\begin{figure}[h] 
\centering  
\subfigure[text]  
{  
\begin{tikzpicture}
\draw (-2,0) arc (180:360:2cm and 0.5cm) -- (0,6) -- cycle;
\draw[densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);

\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (1cm and 0.5cm);
\fill[left color=gray!50!black,right color=gray!50!black,middle color=gray!50,shading=axis,opacity=0.25] (1,0) -- (1,3) arc (360:180:1cm and 0.5cm) -- (-1,0) arc (180:360:1cm and 0.5cm);
\fill[top color=gray!90!,bottom color=gray!2,middle color=gray!30,shading=axis,opacity=0.25] (0,3) circle (1cm and 0.5cm);
\draw (-1,0) -- (-1,3) arc (180:360:1cm and 0.5cm) -- (1,0) ++ (-1,0) circle (1cm and 0.5cm);
\draw[densely dashed] (-1,3) arc (180:0:1cm and 0.5cm);
        \end{tikzpicture}
}  
%
\subfigure[text]  
{  
\begin{tikzpicture}
\draw (-2,0) -- (0,6) -- (2,0) -- (-2,0);

\draw (-1,0) -- (-1,3)  -- (1,3) -- (1,0);
\draw[thick] (0,6) -- (0,0);
\draw[thick] (0,0) -- (-2,0);
\draw[thick] (-2,0) -- (0,6);
\draw[thick] (-1,0) -- (-1,3) node[below] at (-1,-0.4) {$\scriptstyle{a}$} node[right] at (-1,1.5) {$\scriptstyle{v}$};
\draw[thick] (-1,0) -- (-2,0) node[below] at (-1.5,0.1) {$\scriptstyle{a-r}$};
\draw[thick] (-1,3) -- (0,3) node[above] at (-0.5,2.9) {$\scriptstyle{r}$};

\draw[<->] (0.2,6) -- (0.2,0) node[right] at (0.2,2.5) {$\scriptstyle{b}$};
\draw[<->] (-2,-0.4) -- (0,-0.4) ;
\end{tikzpicture}
}
\caption{text}
\label{fig:text}
\end{figure}

\end{document}
7

Don't use subfigure as it is deprecated. Use subcaption or subfig instead. I used subcaption. You can level the baselines appropriately to keep the images at same levels.

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{graphicx}
\usepackage{tikz}                                   % graphics
\usetikzlibrary{shapes.geometric,calc,arrows,decorations.markings,decorations.pathmorphing}
\usepackage{pgfplots}
\usepackage{subcaption}

\begin{document}

\section {First}

text

\begin{figure}[h]
\centering
\subcaptionbox{Text}{%
\begin{tikzpicture}[baseline = {(0,-.8)}]
\draw (-2,0) arc (180:360:2cm and 0.5cm) -- (0,6) -- cycle;
\draw[densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (1cm and 0.5cm);
\fill[left color=gray!50!black,right color=gray!50!black,middle color=gray!50,shading=axis,opacity=0.25] (1,0) -- (1,3) arc (360:180:1cm and 0.5cm) -- (-1,0) arc (180:360:1cm and 0.5cm);
\fill[top color=gray!90!,bottom color=gray!2,middle color=gray!30,shading=axis,opacity=0.25] (0,3) circle (1cm and 0.5cm);
\draw (-1,0) -- (-1,3) arc (180:360:1cm and 0.5cm) -- (1,0) ++ (-1,0) circle (1cm and 0.5cm);
\draw[densely dashed] (-1,3) arc (180:0:1cm and 0.5cm);
        \end{tikzpicture}
}%
%
\quad
\subcaptionbox{Text}{%
\begin{tikzpicture}[baseline = {(0,-.8)}]
\draw (-2,0) -- (0,6) -- (2,0) -- (-2,0);
\draw (-1,0) -- (-1,3)  -- (1,3) -- (1,0);
\draw[thick] (0,6) -- (0,0);
\draw[thick] (0,0) -- (-2,0);
\draw[thick] (-2,0) -- (0,6);
\draw[thick] (-1,0) -- (-1,3) node[below] at (-1,-0.4) {$\scriptstyle{a}$} node[right] at (-1,1.5) {$\scriptstyle{v}$};
\draw[thick] (-1,0) -- (-2,0) node[below] at (-1.5,0.1) {$\scriptstyle{a-r}$};
\draw[thick] (-1,3) -- (0,3) node[above] at (-0.5,2.9) {$\scriptstyle{r}$};

\draw[<->] (0.2,6) -- (0.2,0) node[right] at (0.2,2.5) {$\scriptstyle{b}$};
\draw[<->] (-2,-0.4) -- (0,-0.4) ;
\end{tikzpicture}
}
\caption{text}
\label{fig:text}
\end{figure}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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