我试图让我的图看起来漂亮,但在我看来,我只能让它们看起来还行。我想在图片下方和脚注之前有一个 \decoRule,但我很难让它适合图片。我认为这个 \decoRule 只是一个标准长度,因为我找不到它在文档中的任何地方被定义过。(如果我没有在代码中包含相关的包,我提前表示抱歉,但据我所知,这不需要任何额外的包。
编辑:我现在发现 \decoRule 是由 定义的\newcommand{\decoRule}{\rule{.8\textwidth}{.4pt}} % New command for a rule to be used under figures
。
\documentclass{article}
\begin{document}
\usepackage{graphicx}
\newcommand{\decoRule}{\rule{.8\textwidth}{.4pt}} % New command for a rule to be used under figures
\begin{figure}[ht]
\centering
\caption[An Electron]{Time Series of Consumption Prognosis}
\includegraphics[scale=0.5]{Figures/time_series_consumption}
\decoRule \\
\footnotesize
Hourly consumption prognosis. Released daily, predicting the consumption for all 24 hours of the following day.
\label{fig:3:6}
\end{figure}
\end{document}
答案1
在此代码中,测量图形宽度,并使用该宽度minipage
通过命令插入规则和文本\Figcomment[<code before>]{<\includegraphics[...>}{<text>}
。
可选参数<code before>
允许在注释文本前插入附加命令:字体形状、对齐方式、颜色等。
\documentclass{article}
\usepackage{graphicx}% in the preamble <<<<
\usepackage{xcolor}% optional
%******************************************** added <<<<<<<<<<<<
\newsavebox{\imageboxed}
\newcommand{\Figcomment}[3][]{%
\savebox{\imageboxed}{#2}
\begin{minipage}{\wd\imageboxed}
#2\\[-1.0ex]%
\rule{\linewidth}{.4pt}\\%
#1\footnotesize#3%
\end{minipage}}
%*******************************************
\begin{document}
\begin{figure}[ht]
\centering
\caption[An Electron]{Time Series of Consumption Prognosis}\label{fig:3:6}% label here <<
\Figcomment{\includegraphics[scale=0.5]{example-image-a}}{Hourly consumption prognosis. Released daily, predicting the consumption for all 24 hours of the following day.}
\end{figure}
\begin{figure}[ht]
\centering
\caption[An Electron]{Time Series of Consumption Prognosis}\label{fig:4:6}% label here <<
\Figcomment[\centering]{\includegraphics[height=160pt]{example-image-b}}{Hourly consumption prognosis. Released daily, predicting the consumption for all 24 hours of the following day.}
\end{figure}
\end{document}
如果你添加到序言中,\usepackage{xcolor}
你可以尝试其他变体,\Figcomment
例如
\newcommand{\Figcomment}[3][]{%
\savebox{\imageboxed}{#2}
\begin{minipage}{\wd\imageboxed}
#2\\[-1.0ex]%
{\color{gray}\rule{\linewidth}{0.6pt}}\\[-0.3ex]
#1\footnotesize#3%
\end{minipage}}