移动子图

移动子图

我需要将下图中子图的左侧部分向上移动:

图片1

也就是说,图像应该如下所示:

图片2

因此子图在顶部垂直对齐。

文档:

\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}

答案1

不要使用,subfigure因为它已被弃用。请改用subcaptionsubfig。我使用了subcaption。您可以适当调整基线以使图像保持在同一水平。

\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}

在此处输入图片描述

相关内容