如何正确对齐图形的图例?

如何正确对齐图形的图例?

我有以下代码:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb} % for "\checkmark" macro
\usepackage{graphicx} % remove "demo" option in real document
\usepackage{float} 
\usepackage{caption}
\usepackage{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}
\captionsetup[subfigure]{labelformat=simple}
\makeatletter
\renewcommand{\p@subfigure}{\thefigure~} % unbreakable space after fig. #
\makeatother

\begin{document}

\begin{figure}[ht!]
\centering
%Insere Figura
\caption{Figure Description}
\includegraphics[scale=0.6]{img/tex.png}
\legend{Source: (Blokland2013)}
\label{fig:testemultiplataforma}
\end{figure}

\begin{figure}[!ht]
\centering
\caption{Figure Description}
    \begin{subfigure}{0.5\textwidth}  
            \centering
            \includegraphics[width=\textwidth]{img/tex.png}
            \caption{Figure 1}
            \label{fig:DifExp2Per4Tarefa1IF}
    \end{subfigure}%
    %\qquad
     %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/tex.png}
            \caption{Figure 2}
            \label{fig:DifExp2Per4Tarefa2IF}
    \end{subfigure}
    \legend{Source: Own authorship}
    \label{fig:DifExp2Per4IF}
\end{figure}

\end{document}

在我的原始文档中有命令\legend{},但我已经查看了文件cls和所有包的导入,但我不知道这个命令来自哪里。这个命令来自哪个包?

我应该如何做才能让legend文本左对齐而不是按照下图所示居中?

例子:

在此处输入图片描述

在此处输入图片描述

答案1

据我了解,您喜欢使用图例作为图像源的通知。为此目的已经开发了软件包copyrightbox。通过它您可以获得:

在此处输入图片描述

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb} % for "\checkmark" macro
\usepackage[demo]{graphicx} % remove "demo" option in real document
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{copyrightbox}% <--- added

\renewcommand\thesubfigure{(\alph{subfigure})}
\captionsetup[subfigure]{labelformat=simple}
\makeatletter
\renewcommand{\p@subfigure}{\thefigure~} % unbreakable space after fig. #
%
\renewcommand{\CRB@setcopyrightfont}{% < ---for changing copyright font color/shape/family
\footnotesize
\color{black}% 
            }
\makeatother

\begin{document}
    \begin{figure}[ht!]
\centering
\caption{Figure Description}
\label{fig:testemultiplataforma}
\copyrightbox[b]{\includegraphics[scale=0.6]{img/tex.png}}{Source: Blokland2013}
\end{figure}

\begin{figure}[!ht]
\centering
\caption{Figure Description}
    \label{fig:DifExp2Per4IF}
\copyrightbox[b]{\begin{subfigure}{0.45\textwidth}
            \centering
\includegraphics[width=\textwidth]{img/tex.png}
            \caption{Figure 1}
            \label{fig:DifExp2Per4Tarefa1IF}
    \end{subfigure}\quad
    \begin{subfigure}{0.45\textwidth}
            \centering
\includegraphics[width=\textwidth]{img/tex.png}
            \caption{Figure 2}
            \label{fig:DifExp2Per4Tarefa2IF}
    \end{subfigure}}{Source: Own authorship}
    \end{figure}
\end{document}

编辑: 通过定义新命令legend

\newcommand\legend[1]{%
    \captionsetup{font=small,singlelinecheck=off}
    \caption*{#1}}

你可以获得:

在此处输入图片描述

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb} % for "\checkmark" macro
\usepackage[demo]{graphicx} % remove "demo" option in real document
\usepackage{float}
\usepackage{caption}
\newcommand\legend[1]{%
    \captionsetup{font=small,singlelinecheck=off}
    \caption*{#1}}
\usepackage{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}
\captionsetup[subfigure]{labelformat=simple}
\makeatletter
\renewcommand{\p@subfigure}{\thefigure~} % unbreakable space after fig. #
\makeatother

\begin{document}
    \begin{figure}[ht!]
\centering
\caption{Figure Description}
\label{fig:testemultiplataforma}
\includegraphics[scale=0.6]{img/tex.png}%}{Source: Blokland2013}
\legend{Source: Blokland2013}
\end{figure}

\begin{figure}[!ht]
\centering
\caption{Figure Description}
    \label{fig:DifExp2Per4IF}
\begin{subfigure}{0.45\textwidth}
            \centering
\includegraphics[width=\textwidth]{img/tex.png}
            \caption{Figure 1}
            \label{fig:DifExp2Per4Tarefa1IF}
\end{subfigure}\quad
\begin{subfigure}{0.45\textwidth}
            \centering
\includegraphics[width=\textwidth]{img/tex.png}
            \caption{Figure 2}
            \label{fig:DifExp2Per4Tarefa2IF}
\end{subfigure}
\legend{Source: Own authorship}
    \end{figure}
\end{document}

答案2

使用该copyrightbox包非常简单:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{ebgaramond}
\usepackage{graphicx}
\usepackage{copyrightbox}
\usepackage{caption}

\begin{document}

    \begin{figure}[!htb]
        \centering
\caption{Heinrich Füssli – The Nightmare (1781)}
        \copyrightbox[b]{\includegraphics{Nightmare_Fussli}}{Detroit Institute of Arts}
    \end{figure}%

\end{document} 

在此处输入图片描述

允许的展示位置使用可选参数:[l][r](默认)或[b]

相关内容