0

I am trying to make my figures look nice, but I can only make them look OK, imo. I want to have a \decoRule under the figure and before the footnote, but I am struggling to make it fit the figure. I think this \decoRule is just a standard length, since I can't find that it has been defined anywhere in the document. (I sorry beforehand if I don't include the relevant packages in the code, but as far as I know this doesn't require any additional packages.

EDIT: I have found now that \decoRule is defined by \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}

enter image description here

1
  • I honestly think the fixed-width \decoRule you have is better than something that changes with the width/size of the image.
    – Werner
    Sep 6 at 15:49

1 Answer 1

0

In this code the figure width is measured and that width is used to insert a minipage with a rule and text using the \Figcomment[<code before>]{<\includegraphics[...>}{<text>} command.

The optional parameter <code before> allows inserting additional commands before the comment text: font shape, justification, color, etc.

c

\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}

If you add to the preamble \usepackage{xcolor} you can try other variants of \Figcomment like

\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}} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .