0

Comments from various threads have been aggregated and considered resulting in the following implementation.

\documentclass{article}%
\usepackage{afterpage}%
\usepackage{pdflscape}%
\usepackage{varioref}%
\usepackage{graphicx}%
\usepackage{capt-of}%

%
\newcommand\floatsummary{}%
\newcommand\floatdescription{}%

\begin{document}

\section{Introduction}

An introduction...

\section{Results}

Results are shown in Figure \vref{fig:example}


%
\afterpage{%
\begin{landscape}%
\pagestyle{empty}
\parbox[c][\textwidth][s]{\linewidth}{%
%
\renewcommand\floatsummary{Short float summary which will appear in toc}%
\renewcommand\floatdescription{Longer float description}%
%
\vfill%
\setlength{\fboxrule}{0pt}%
\begin{center}%
\fbox{%
\centering%
\includegraphics[width=\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax]{example-image.jpg}\\%
}%
\end{center}%
\captionof{figure}[\floatsummary]{\floatsummary.  \floatdescription}%
\vfill%
}%
\label{fig:example}%
\end{landscape}%
}%

\end{document}

Key, desireable features are:

  1. balanced positioning
  2. maximizing use of page
  3. rotating landscape pages in .pdf
  4. avoid blank pages before or after figure
  5. avoid blank pages when two or more consecutive landscape figures displayed

The inset mwe does result in a .pdf when one pushes compilation through a couple of errors. The question is, what causes the ! LaTeX Error: Something's wrong--perhaps a missing \item. and how can the mwe be optimized / improved?

3
  • Removing the \\ after ...{example-image.jpg} helps.
    – John Chris
    Oct 13, 2020 at 8:44
  • Removing the \begin{center} ... \end{center} reveals at first glance that it may not do much.
    – John Chris
    Oct 13, 2020 at 8:47
  • 1
    Also, \centering inside an \fbox makes no sense as the \fbox is only wide enough to fit the contents. In fact, all the fbox is doing is putting a \fboxsep (2pt) border around the image. You can lose the \vfills if you use [c] instead of [s] in the \parbox. Oct 13, 2020 at 14:08

1 Answer 1

2

This version simplifies the code as much as possible.

I regard the purpose of \newcommand to be reserving global names. For local definitions I use \def.

The purpose of adding % at the ends of lines is to prevent extra spaces. It is only needed when lines end with braces, and not always then either. For example, \caption begins and ends with a \par which absorbs extra spaces.

\documentclass{article}%
\usepackage{afterpage}%
\usepackage{pdflscape}%
\usepackage{varioref}%
\usepackage{graphicx}%
\usepackage{capt-of}%

\begin{document}

\section{Introduction}

An introduction...

\section{Results}

Results are shown in Figure \vref{fig:example}
%
\afterpage{%
\begin{landscape}%
\pagestyle{empty}
\parbox[c][\textwidth][c]{\linewidth}{%
%
\def\floatsummary{Short float summary which will appear in toc}% local to environment
\def\floatdescription{Longer float description}%
%
\centering
\includegraphics[width=\linewidth]{example-image.jpg}
\captionof{figure}[\floatsummary]{\floatsummary.  \floatdescription}
\label{fig:example}% \@currentlabel etc. is local to \parbox
}% end of \parbox
\end{landscape}%
}%

\end{document}
1
  • Thank you very much for your suggestion: now I have done another similar question with an old mwe.
    – Sebastiano
    Oct 14, 2020 at 21:35

You must log in to answer this question.

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