1

I have quite a long figure which I need to adjust to fit to textheight. When I want to include some description below, the figure stop being centered and indents the text. I tried this suggestion to use \floatfoot, but it did not help. Any ideas? Can I place a box inside the figure environment?

Here is an MWE

 \documentclass[12pt]{article}

\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref, bm}

\usepackage[T1]{fontenc} \usepackage[american]{babel} \usepackage{csquotes} \usepackage[flushleft]{threeparttable} \usepackage{amsthm,amsmath} %\RequirePackage[numbers]{natbib} %\RequirePackage[authoryear]{natbib}% uncomment this for author-year bibliography %\RequirePackage{hyperref} \usepackage{booktabs} \usepackage{tabularx} \usepackage{graphicx} \usepackage{adjustbox} \usepackage{textcomp} \usepackage{mathtools} \usepackage{setspace} \usepackage{lipsum}

\usepackage[skip=1ex, font=small, textfont=it]{caption}

\makeatletter \newlength{\fnBreite} \renewcommand{@makefntext}[1]{% \settowidth{\fnBreite}{\footnotesize@thefnmark.i} \protect\footnotesize\upshape% \setlength{@tempdima}{\columnwidth}\addtolength{@tempdima}{-\fnBreite}% \makebox[\fnBreite][l]{@thefnmark.\phantom{}}% \parbox[t]{@tempdima}{\everypar{\hspace{1em}}\hspace{-1em}\upshape#1}} \makeatother

\normalem

\newtheorem{theorem}{Theorem} \newtheorem{corollary}[theorem]{Corollary} \newtheorem{proposition}{Proposition}

\newtheorem{hyp}{Hypothesis} \newtheorem{subhyp}{Hypothesis}[hyp] \renewcommand{\thesubhyp}{\thehyp\alph{subhyp}}

\newcommand{\red}[1]{{\color{red} #1}} \newcommand{\blue}[1]{{\color{blue} #1}}

\usepackage[backend=biber, style=authoryear]{biblatex}

\makeatletter

\newrobustcmd*{\parentexttrack}[1]{% \begingroup \blx@blxinit \blx@setsfcodes \blx@bibopenparen#1\blx@bibcloseparen \endgroup}

\AtEveryCite{% \let\parentext=\parentexttrack% \let\bibopenparen=\bibopenbracket% \let\bibcloseparen=\bibclosebracket} \makeatother

\addbibresource{bib.bib} \begin{document}

\begin{figure}[hp] \centering \captionsetup{font=small,labelfont=small} \caption{\textit{Title}}\label{fig:lpoly} \includegraphics[width=\textwidth, height=0.9\textheight, keepaspectratio]{fig1.png} \medskip \floatfoot{\scriptsize{Sources: \lipsum[1] \lipsum[1]}} \end{figure}

\end{document}

Here is the picture

Output

Papayapap
  • 421
  • 2
    Please don't post fragments of code. Instead, put the fragment into a complete compilable document that people can play with. That's what a MWE is. – Alan Munn Apr 28 '21 at 21:34
  • Thanks, done. This reproduces the error with my figure. – Papayapap Apr 29 '21 at 08:26
  • 2
    This error has nothing to do with centering, what is \floatfoot? And its argument is not closed. And please keep your examples minimal, you're loading a lot of packages that are irrelevant for your problem – daleif Apr 29 '21 at 08:32
  • 2
    Unrelated: \scriptsize does not take any argument. You should not be using \caption{\textit{Title}}, it you want italig caption, use the caption setup to configure it. – daleif Apr 29 '21 at 08:33
  • If I remove \floatfoot (you not load floatrow package) your example works fine. Anyway, please consider settings in my answer. Also purpose of it is unclear in your case. BTW, in preamble you have big mess. Do you really need all those packages. At list load it in correct order. – Zarko Apr 29 '21 at 08:39
  • This was the suggestion in the other question I referenced. Removing this does not solve it. Which setting do you mean? I included now \usepackage[skip=1ex, font=small, textfont=it]{caption}
            and it still gives me the error.
    
    – Papayapap Apr 29 '21 at 08:42
  • But stil not consider this in your figure :-(. Please show your of your compilation of the provided document example – Zarko Apr 29 '21 at 08:43
  • Sorry, I had it only in my own document. Added now to MWE and also a picture of my output – Papayapap Apr 29 '21 at 08:48

1 Answers1

1
  • It is not clear, what is your problem.
  • Inserting your code fragment after moving caption settings to document preamble into some MWE (Minimal Working Example), a small but complete document, gives the following result:

enter image description here

(redlines indicate document's page layout)

  • As you can see, result looks fine
  • MWE, which was produced above image is:
\documentclass{article}
\usepackage[skip=1ex,
            font=small,
            textfont=it]{caption}
\usepackage{graphicx}

%---------------- Show page layout. Don't use in a real document! \usepackage{showframe} \renewcommand\ShowFrameLinethickness{0.15pt} \renewcommand*\ShowFrameColor{\color{red}} %---------------------------------------------------------------% \usepackage{lipsum}% For dummy text. Don't use in a real document

\begin{document} \begin{figure}[hp] % \centering \caption{Fig title} \label{fig:one} \includegraphics[width=\textwidth, height=0.8\textheight]{example-image-a}%, keepaspectratio

\medskip \scriptsize Sources: So here I will also want to put a lot of description even though the figure is already fitted to page size. \lipsum[1] \end{figure} \end{document}

  • Observe empty row before \medskip command in figure` float environment!
  • For help you, you need to provide your MWE, which reproduce your problem.

Edit: Considering your document preamble in edited question after clean up all duplicates and grouping loading packages according to their use, and consider body of my original MWE with used example image, I still can't reproduce your problem. Cleaned preamble of your document is (can be) as follows:

\documentclass[12pt]{article}
\usepackage{geometry}

%---------------- Show page layout. Don't use in a real document! \usepackage{showframe} \renewcommand\ShowFrameLinethickness{0.15pt} \renewcommand*\ShowFrameColor{\color{red}} %---------------------------------------------------------------% \usepackage{lipsum}% For dummy text. Don't use in a real document

% fonts, encoding, babel \usepackage[T1]{fontenc} \usepackage{eurosym, textcomp} \usepackage[american]{babel} % math \usepackage{amssymb, bm, mathtools} % amssymb contain amsfonts % mathtools contain amsmath \newtheorem{theorem}{Theorem} \newtheorem{corollary}[theorem]{Corollary} \newtheorem{proposition}{Proposition}

\newtheorem{hyp}{Hypothesis} \newtheorem{subhyp}{Hypothesis}[hyp] \renewcommand{\thesubhyp}{\thehyp\alph{subhyp}}

% tables \usepackage{array, booktabs, tabularx} \usepackage[flushleft]{threeparttable} % figures and captions \usepackage[export]{adjustbox} % also load graphicx \usepackage{subfig} % subfigure is obsolete \usepackage[skip=1ex, font=small, textfont=it]{caption}

\usepackage{xcolor} \newcommand{\red}[1]{{\color{red} #1}} \newcommand{\blue}[1]{{\color{blue} #1}}

% formattings \usepackage{csquotes, comment, footmisc} \usepackage{setspace} \usepackage{sectsty} \usepackage{pdflscape}

\makeatletter \newlength{\fnBreite} \renewcommand{@makefntext}[1]{% \settowidth{\fnBreite}{\footnotesize@thefnmark.i} \protect\footnotesize\upshape% \setlength{@tempdima}{\columnwidth}\addtolength{@tempdima}{-\fnBreite}% \makebox[\fnBreite][l]{@thefnmark.\phantom{}}% \parbox[t]{@tempdima}{\everypar{\hspace{1em}}\hspace{-1em}\upshape#1}} \makeatother \usepackage{ulem} \normalem

% bibliography \usepackage[backend=biber, style=authoryear]{biblatex} \makeatletter \newrobustcmd*{\parentexttrack}[1]{% \begingroup \blx@blxinit \blx@setsfcodes \blx@bibopenparen#1\blx@bibcloseparen \endgroup}

\AtEveryCite{% \let\parentext=\parentexttrack% \let\bibopenparen=\bibopenbracket% \let\bibcloseparen=\bibclosebracket} \makeatother

\addbibresource{bib.bib} % so far unknow

\usepackage{hyperref} % had to be loaded last % except in rare exception (as is cleveref) % which seems not to be present in your document

\begin{document}

Using it instead preamble in above MWE gives the same result as is already shown in original answer.

Since your original image is unknown to me, I can't test my MWE with it. So it can happen that it has large white space on its right side which consequently move visible part of image to the left border of figure float environment. This can you check with enclosing image in fbox:

   \fbox{
\includegraphics[width=\textwidth, height=0.8\textheight]{example-image-a}
         }

and look if the frame is tied to image. If it is not, than you need with some tool cut-out white space or redrawn image with help of some LaTeX package (˙tikz˙, pgfplots, ps trick`, etc).

Zarko
  • 296,517