我有两个子图,它们有共同的标题,另外两个子图也有共同的标题。我需要类似附件的东西。其中“abc”和“time(s)”是标签。请帮我获取 latex 代码。谢谢,Sivakumar
\begin{figure}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\frame{\includegraphics[width=1\textwidth]{images/con_thd1}
\includegraphics[width=1\textwidth]{images/conv_thd2}}
\caption{ MPC2}
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\frame{\includegraphics[width=1\textwidth]{images/PROP1_thd1}
\includegraphics[width=1\textwidth]{images/prop1_thd2}}
\caption{MPC1}
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
\centering
\frame{\includegraphics[width=1\textwidth]{images/PROP_thd1}
\includegraphics[width=1\textwidth]{images/prop_thd2}}
\caption{MPC}
\end{subfigure}
\caption{Steady-state results }
\end{figure}
答案1
像这样?
实现您想要的目标的一种方法是向tikzpicture
图像添加框架和标签。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,
positioning}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\setkeys{Gin}{width=66mm, height=33mm}
\begin{tikzpicture}[node distance = 6mm]
\node[draw,
label=below: time (seconds),
label={[rotate=90, anchor=south]left:abc}
] (fig-1)
{\includegraphics{example-image-duck}};
\node[draw, below=of fig-1,
label=below: time (seconds),
label={[rotate=90, anchor=south]left:abc}
] (fig-2)
{\includegraphics{example-image-duck}};
\node[draw,inner sep=2em, fit=(fig-1) (fig-2)] {};
\end{tikzpicture}
\caption{full caption}\label{fig:two-fig}
\end{figure}
\end{document}
笔记: 你的问题不太清楚。我们没有任何信息,你的图片包含什么,是图形文件还是借助某些 LaTeX 包绘制的?图片外面应该添加标签,这很不寻常。这应该是(在正常情况下)图像的一部分,所以我担心你的问题实际上是XY问题。
编辑:
感谢您添加的代码片段,它展示了您迄今为止所做的工作。但是,这里希望提供 MWE(最小工作示例),这是一个完整的小文档,可以重现您的问题。您可以在上面看到 MWE 的示例。这意味着,您的代码片段应该扩展到 MWE,即:在\end{document}
片段末尾添加文档前言,其中包含加载到问题相关包的内容。
在您的代码片段中使用我建议的解决方案是:
% \documentclass which one you use?
% existed preamble
\usepackage[belowskip=1ex]{subcaption} % need to be added
\begin{document}
\begin{figure}
\centering
\setkeys{Gin}{width=\linewidth, height=33mm}
\begin{subfigure}[t]{0.45\textwidth}
\begin{tikzpicture}[node distance = 6mm]
\node[draw,
label=below: time (seconds),
label={[rotate=90, anchor=south]left:abc}
] (fig-1)
{\includegraphics{example-image-duck}};
\node[draw, below=of fig-1,
label=below: time (seconds),
label={[rotate=90, anchor=south]left:abc}
] (fig-2)
{\includegraphics{example-image-duck}};
\node[draw,inner sep=2em, fit=(fig-1) (fig-2)] {};
\end{tikzpicture}
\caption{ MPC1}
\end{subfigure}
\begin{subfigure}[t]{0.45\textwidth}
\begin{tikzpicture}[node distance = 6mm]
\node[draw,
label=below: time (seconds),
label={[rotate=90, anchor=south]left:abc}
] (fig-1)
{\includegraphics{example-image-duck}};
\node[draw, below=of fig-1,
label=below: time (seconds),
label={[rotate=90, anchor=south]left:abc}
] (fig-2)
{\includegraphics{example-image-duck}};
\node[draw,inner sep=2em, fit=(fig-1) (fig-2)] {};
\end{tikzpicture}
\caption{ MPC2}
\end{subfigure}
\caption{full caption}\label{fig:two-fig}
\end{figure}
\end{document}