我如何为并排的 tikzfigures 添加子字幕?

我如何为并排的 tikzfigures 添加子字幕?

我正在尝试应用以下解决方案并排放置两个 Tikz 图像。在哪里可以分别通过(a)和标记/标签 Tikzfigures (b)

\documentclass[a4paper, 12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage[showframe]{geometry}
\begin{document}
\begin{figure}[ht]
    \centering
    \begin{tikzpicture}[scale=1.2,line width=1pt]
        \begin{axis}[
            color= gray,
            xmin=-9,
            xmax=9,
            ymin=-9,
            ymax=9,
            axis equal image,
            axis lines=middle,
            xticklabels={},
            yticklabels={},
            font=\scriptsize,
            ticks=none,
            xlabel = $x$,
            ylabel = $y$,
            inner axis line style={stealth-stealth}
            ]

            \draw[blue, fill=blue, fill opacity=0.20, dashed] plot [smooth cycle]
            coordinates {(-6,0) (-4,2) (-3,6) (-1.5,6) (1,4) (3,6) (5,2) (2,-1) (4,-4)
                (3,-5) (0,-6) (-3,-5)};
            \filldraw[black] (3,6) circle (0pt) node[above right] {$D$};
            \filldraw[black, fill opacity=1] (-2,-2) circle (1.5pt) node[above right]
            {$z$};

        \end{axis}
    \end{tikzpicture}
    \qquad
    \begin{tikzpicture}[scale=1.2,line width=1pt]
        \begin{axis}[
            color= gray,
            xmin=-9,
            xmax=9,
            ymin=-9,
            ymax=9,
            axis equal image,
            axis lines=middle,
            xticklabels={},
            yticklabels={},
            font=\scriptsize,
            ticks=none,
            xlabel = $u$,
            ylabel = $v$,
            inner axis line style={stealth-stealth}
            ]

            \draw[black, ultra thin, dashed] (0,0) circle [radius=5];
            \draw[black] (-3.525,3.525) circle (0pt) node[above left] {$|f|$};
            \filldraw[black, fill opacity=1] (3.525,3.525) circle (1.5pt) node[above
            right] {$f$};

        \end{axis}
    \end{tikzpicture}
    \caption{Mapping a point $z=x+iy$ in $D$ onto $f=u+iv$ when $|f|$ is
        constant.}
\end{figure}
\end{document}

enter image description here

想要的输出:

[tikzpicture_1]   [tikzpicture_2]
     (a)               (b)
Figure 1: Mapping a point....

我也想在文中引用 a 和 b。

答案1

使用包subcaption并将每个包封装tikzpicture在环境中subfigure。在子图上使用空标题以仅获取 (a) 和 (b),然后添加标签。

文中引用一下subfigure用法\subref{<label>}

更新在后续问题之后。

要在文中将子图引用为“1.a”,请改用\ref{<label>}

c

\documentclass[a4paper, 12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage[showframe]{geometry}

\usepackage{subcaption}% added  <<<<<
\captionsetup{subrefformat=parens}

\makeatletter
\renewcommand\p@subfigure{\thefigure.} % added <<<<<<<<<<<<<
\makeatother

\begin{document}
    \begin{figure}[ht]  
        \begin{subfigure}[b]{0.47\textwidth}
            \centering % in here <<<
            \begin{tikzpicture}[scale=1.2,line width=1pt]
                \begin{axis}[
                    color= gray,
                    xmin=-9,
                    xmax=9,
                    ymin=-9,
                    ymax=9,
                    axis equal image,
                    axis lines=middle,
                    xticklabels={},
                    yticklabels={},
                    font=\scriptsize,
                    ticks=none,
                    xlabel = $x$,
                    ylabel = $y$,
                    inner axis line style={stealth-stealth}
                    ]
                    
                    \draw[blue, fill=blue, fill opacity=0.20, dashed] plot [smooth cycle]
                    coordinates {(-6,0) (-4,2) (-3,6) (-1.5,6) (1,4) (3,6) (5,2) (2,-1) (4,-4)
                        (3,-5) (0,-6) (-3,-5)};
                    \filldraw[black] (3,6) circle (0pt) node[above right] {$D$};
                    \filldraw[black, fill opacity=1] (-2,-2) circle (1.5pt) node[above right]
                    {$z$};              
                \end{axis}
            \end{tikzpicture}
            \caption{\label{sub:left}}
        \end{subfigure}
        \hfill
        \begin{subfigure}[b]{0.47\textwidth}   
                \centering 
            \begin{tikzpicture}[scale=1.2,line width=1pt]
                \begin{axis}[
                    color= gray,
                    xmin=-9,
                    xmax=9,
                    ymin=-9,
                    ymax=9,
                    axis equal image,
                    axis lines=middle,
                    xticklabels={},
                    yticklabels={},
                    font=\scriptsize,
                    ticks=none,
                    xlabel = $u$,
                    ylabel = $v$,
                    inner axis line style={stealth-stealth}
                    ]
                    
                    \draw[black, ultra thin, dashed] (0,0) circle [radius=5];
                    \draw[black] (-3.525,3.525) circle (0pt) node[above left] {$|f|$};
                    \filldraw[black, fill opacity=1] (3.525,3.525) circle (1.5pt) node[above
                    right] {$f$};
                    
                \end{axis}
            \end{tikzpicture}
            \caption{\label{sub:right}}
        \end{subfigure}
        \caption{Mapping a point $z=x+iy$ in $D$ onto $f=u+iv$ when $|f|$ is
            constant.}\label{fig:main}
    \end{figure}
    
    See the figures  \subref{sub:left} and \subref{sub:right} in the Figure \ref{fig:main}.\bigskip
    
    
    See the figures  \ref{sub:left} and \ref{sub:right} in the Figure \ref{fig:main}.
    
    \end{document}

相关内容