对于我的学士论文,我依靠 pgf 来绘制图表。
在 groupplot 环境中,我创建一个节点来标记每个子图,如下所示:
\node at (x,y) {
\textbf{a)}
\addtocounter{gifure}{1}
\captionof{subfigure}[minimal name]{}
\addtocounter{giure}{-1}
};
为了正常工作,' \addtocounter
s 是必需的。\ref
到目前为止一切都很好,但是当我创建图像列表时,乳胶会将这些\captionof
图像视为属于前一个图像。我提供了一个最小的工作示例:
主要.tex:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepgfplotslibrary{groupplots}
\usepackage{caption}
\captionsetup{width=\textwidth,labelfont=bf}
\usepackage{subcaption}
\usepackage{blindtext}
\begin{document}
\section{Hello World}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}
\addplot[blue,domain=-1:1] {1 - x^2 + x^4};
\end{axis}
\end{tikzpicture}
\caption{The First Plot}
\label{first plot}
\end{figure}
\begin{figure}[!b]
\centering
\input{plots.tikz}
\caption{Two beautiful plots.}
\label{more plots}
\end{figure}
The first Plot \ref{first plot}. The second plots \ref{more plots}, \ref{2. plot a}, \ref{2. plot b}.
Everything works excellent!
\listoffigures
\end{document}
图.tikz:
% !TeX root = main.tex
\begin{tikzpicture}
\begin{groupplot}[group style={group size=2 by 1,
horizontal sep =0.1\textwidth},
height=0.45\textwidth,width=0.45\textwidth,]
%%%%%
% 1x1
\nextgroupplot[ylabel=$y_1$,
xlabel=$x$,]
\addplot[blue,domain=0:5,] {exp(-0.5*x)*sin(rad(x))};
% subplot name
\node[text width=0.3\textwidth,anchor=north west] (Subplot a) at (rel axis cs: 0.05,0.95)
{
\textbf{a)}
\addtocounter{figure}{1}
\captionof{subfigure}[Second plot first part]{\label{2. plot a}}
\addtocounter{figure}{-1}
};
%%%%%
% 2x1
\nextgroupplot[ylabel=$y_2$,
xlabel=$x$,]
\addplot[blue,domain=-1:1,] {-x*x + 2*x};
% subplot name
\node[text width=0.3\textwidth,anchor=north west] (Subplot b) at (rel axis cs: 0.05,0.95)
{
\textbf{b)}
\addtocounter{figure}{1}
\captionof{subfigure}[Second plot second part]{\label{2. plot b}}
\addtocounter{figure}{-1}
};
\end{groupplot}
\end{tikzpicture}
答案1
不要手动完成所有这些操作。您正在加载subcaption
,因此只需将list=true
其作为选项添加,然后\subcaption
在节点中使用即可。也就是说,使用
\usepackage[list=true]{subcaption}
并将你的标签节点替换为类似
\node[text width=1cm,inner sep=0pt,anchor=north west] (Subplot a) at (rel axis cs: 0,1)
{\subcaption[Second plot first part]{\label{2. plot a}}};
我缩小了text width
,将其设置inner sep
为零,将坐标改为(rel axis cs:0,1)
,并将所有内容替换为\subcaption
。结果: