TransWikia.com

Optimization of solution for full page landscape figures

TeX - LaTeX Asked on January 29, 2021

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

%
newcommandfloatsummary{}%
newcommandfloatdescription{}%

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}{%
%
renewcommandfloatsummary{Short float summary which will appear in toc}%
renewcommandfloatdescription{Longer float description}%
%
vfill%
setlength{fboxrule}{0pt}%
begin{center}%
fbox{%
centering%
includegraphics[width=dimexprlinewidth-2fboxsep-2fboxrulerelax]{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?

One Answer

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}{%
%
deffloatsummary{Short float summary which will appear in toc}% local to environment
deffloatdescription{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}

Answered by John Kormylo on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP