圖片下方有一個標題,側面有一個標題/圖例

圖片下方有一個標題,側面有一個標題/圖例

我正在尋找一種在圖像側面添加圖例的方法,同時仍將標題保留在下面。

我目前有以下程式碼:

\begin{figure}
\centering
\includegraphics[height=4cm]{example-image-a}
\caption{
    This is my caption
}
\label{fig:this-is-my-label}
\end{figure}

結果如下圖所示:

上述程式碼的結果截圖

所以基本上我現在正在尋找一種在圖像的右側或左側添加圖例的方法。先致謝!

答案1

透過環境minipage中兩個並排的工具figure,您可以實現以下目標:

在此輸入影像描述

\documentclass{article}

\usepackage{graphicx}
\usepackage[export]{adjustbox}

\begin{document}

\begin{figure}
\begin{minipage}{0.725\textwidth}
\hfill
\includegraphics[height=4cm]{example-image-a}
\end{minipage}
\hfill
\begin{minipage}{0.2\textwidth}
This is my legend. This is my legend.  This is my legend.  This is my legend.  This is my legend. 
\end{minipage}
\caption{This is my caption}
\label{fig:this-is-my-label}
\end{figure}

\begin{figure}
\begin{minipage}{0.2\textwidth}
This is my legend. This is my legend.  This is my legend.  This is my legend.  This is my legend. 
\end{minipage}
\hfill
\begin{minipage}{0.725\textwidth}
\includegraphics[height=4cm]{example-image-a}
\end{minipage}
\caption{This is my caption}
\label{fig:this-is-my-label}
\end{figure}

\begin{figure}
\begin{minipage}[t]{0.725\textwidth}
\hfill
\includegraphics[height=4cm,valign=t]{example-image-a}
\end{minipage}
\hfill
\begin{minipage}[t]{0.2\textwidth}
This is my legend. This is my legend.  This is my legend.  This is my legend.  This is my legend. 
\end{minipage}
\caption{This is my caption}
\label{fig:this-is-my-label}
\end{figure}

\end{document}

答案2

在此輸入影像描述

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{tabularx}

\begin{document}
    \begin{figure}[ht]
\centering
\begin{tabularx}{0.8\linewidth}{XX}
\includegraphics[height=4cm, width=\linewidth, keepaspectratio,
                 valign=c]{example-image-duck} 
    &   Legend: some long explanation of image  \\
\caption{This is my caption in two lines}
\label{fig:this-is-my-label}
    &
    \end{tabularx}
    \end{figure}
or
    \begin{figure}[ht]
\centering
\begin{tabularx}{0.8\linewidth}{XX}
\includegraphics[height=4cm, width=\linewidth, keepaspectratio,
                 valign=c]{example-image-duck}
    &   Legend: some long explanation of image  \\
    \end{tabularx}
\caption{This is my caption in one line}
\label{fig:this-is-my-label}
    \end{figure}
\end{document}

相關內容