4

I'm having issues including large images in landscape mode

This is about as large as the image will render

Changing the size makes the orientation switch

Ideally I'd like to be able to have a large image on this landscape page, that's the reason that I've made the page landscape.

Also, it's important that the page within the pdf is rotated 90 degrees (which is currently the case), so that when reading the document on a screen I don't have to tilt my head to view landscape pages. I would like to retain that in any solution please.

Here's the example code

\documentclass{article}
\usepackage[margin=1.0in]{geometry}

% so that i can crop images
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{epstopdf}
\usepackage{pdflscape}
\usepackage{showframe}
\usepackage[paper=portrait,pagesize]{typearea}


% this is needed for positioning images
\usepackage{float}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the image from this link : https://i.imgur.com/CN1gsF4.png
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Required this package for including graphics and landscaping
% \usepackage[paper=portrait,pagesize]{typearea}
% Link to the stack post
% https://tex.stackexchange.com/a/430619/69118

%%%%%%%%%%%%%%%%
% IMAGE TEST ONE
%%%%%%%%%%%%%%%%

\clearpage
\newpage
% Probably don't want the header for this page, so suppress it
% \thispagestyle{plain}
\thispagestyle{empty}
\newgeometry{left=1cm,bottom=0.1cm}
\KOMAoptions{paper=landscape,pagesize}
\recalctypearea
\begin{figure}[ht]
    \fbox{%
     \includegraphics[width=0.7\textwidth]{test.png}
    }
\end{figure}
\newpage
\KOMAoptions{paper=portrait,pagesize}
\recalctypearea
\restoregeometry
\cleardoublepage

\end{document}

For when / if the image stops being hosted here's it's size :

file image-testing.png 
image-testing.png: PNG image data, 1600 x 1200, 8-bit/color RGBA, non-interlaced

Edit - code for zarko

\documentclass{article}

\usepackage[margin=1.0in,bottom=1.0in]{geometry}

% so that i can crop images
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage{epstopdf}
\usepackage{pdflscape}


% this is needed for positioning images
\usepackage{float}
\usepackage{lipsum}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the image from this link : https://i.imgur.com/CN1gsF4.png
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Required this package for including graphics and landscaping
% \usepackage[paper=portrait,pagesize]{typearea}
% Link to the stack post
% https://tex.stackexchange.com/a/430619/69118

%%%%%%%%%%%%%%%%
% IMAGE TEST ONE
%%%%%%%%%%%%%%%%

\clearpage
\newpage

\thispagestyle{empty}
\begin{landscape}
    \centering
\thispagestyle{empty}
\begin{figure}%[htb]
     \includegraphics[width=\linewidth]{test.png}
    \caption{This is some caption text that I'm using to see what this looks like with caption text. I'm not too sure about 
    adding text in the landscape environment, as I }
\end{figure}
\end{landscape}


\end{document}
baxx
  • 709
  • 1
    Do you really need KOMAscript ? Because without it much simple to do: https://tex.stackexchange.com/questions/50070/landscape-figure-in-latex – G. Bay Jan 03 '19 at 12:42
  • I'm not sure, I know that this seems to work with regards to (1) formatting the page into landscape (2) rotating the page 90 degrees in the PDF file so that I don't have to tilt my head. If there's a version that does that without KOMAscript then that's alright, but this seems to work. I'm not sure how this relates to increasing the actual size of the image though? Thanks – baxx Jan 03 '19 at 12:47

2 Answers2

5
  • showframe in document with some page in landscape environment doesn't show correct page borders for landscape pages
  • in landscape page you should for image width use \linewidth since \textwidth is not changed
  • please use just one package for landscape orientation, not both: lscape and pdflscape (both will give in printed document the same result, but on screen pdflcsape rotate landscape page for simpler view of it content)

the following mwe, in which i omit all packages not relevant to your problem.

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{pdflscape}

\usepackage{showframe}
\usepackage{lipsum}

\begin{document}
\thispagestyle{empty}
\lipsum[1]
\begin{landscape}
\noindent%
XXX \hfill XXX % for show width of text area
\begin{figure}[htb]
\fbox{
     \includegraphics[width=\dimexpr\linewidth-4\fboxsep-2\fboxrule]{test.png}
     }
\end{figure}
\end{landscape}
\lipsum[2]
\end{document}

gives

enter image description here

addendum: now with caption and example image (instead it you should use your image) and removed stuff which in previous solution show size of text area.

\documentclass{article}
\usepackage{geometry}% added  nut it not influence on solution

\usepackage{graphicx}
\usepackage{pdflscape}

\usepackage{lipsum}

\begin{document}
\thispagestyle{empty}
\lipsum[1]
\begin{landscape}
    \begin{figure}[htb]
\includegraphics[width=\linewidth]{example-image-duck}% example image provided by "graphicx"
\caption{This is some caption text that I'm using to see what this looks like with caption text. I'm not too sure about adding text in the landscape environment, as I use in my real document ... sorry, i can use image provided by you in \texttt{igmur}.}
\label{fig:landscape}
    \end{figure}
\end{landscape}
\lipsum[2]
\end{document}

enter image description here

as you can see,image is centered in text area. since now fbox is removed, the width of image is determined only by \linewidth

Zarko
  • 296,517
  • I'm not sure why you have used \includegraphics[width=\dimexpr\linewidth-4\fboxsep-2\fboxrule]{test.png} rather than \includegraphics[width=\linewidth]{test.png} for the width parameter? The image is larger though, thank you. It seems as though the image is off centre though, is there a way to make it so that the image is formatted more centrally? I've tried adding \centering to your code, which didn't seem to work. When there's a caption the image looks particularly skew on the page. – baxx Jan 03 '19 at 13:10
  • @baxx, i reduce size of image so mach that frame around it is not larger than available space for it. if you will not use a fbox, than the image with should be simple \linewidth. image will be better centered if you will remove figure positioning option [htb] and added text in landscape environment. – Zarko Jan 03 '19 at 13:18
  • Thanks, I'm not too sure what you mean about adding the text to the landscape section, as ideally I'd be adding an image caption like I would to any other image? Here's a screen shot of what I mean : https://i.imgur.com/9m71yPE.png , it's a bit skewed on the page? I can't seem to find examples of this being formatted nicely though. I have edited the post to include the code used for this image. – baxx Jan 03 '19 at 13:40
  • @baxx, i added text only to show the size of text area (see comment at this line!). since i haven't your image, i just use demo option for black box. please test proposed solution with your image (and before remove demo option). – Zarko Jan 03 '19 at 13:44
  • Right, I meant that I wanted to add a caption to the image, I wasn't referring to the temporary text that you had added, sorry. And I'm wondering how to do so and have the image centred on the page. I have used the proposed solution with my image, and I'm commenting with respect to that – baxx Jan 03 '19 at 13:52
  • my graphics doesn't have the duck unfortunately, I do have golden-ratio though. I think that this should be enough for anyone in a similar position in future to get something reasonable, and that anything further might be a separate question. Thank you – baxx Jan 03 '19 at 14:41
2

Just using landscape works fine ( I did my own version of your image, lol).

This solution ensures that when/if printing the page will be printed as usual and the person reading will have to tilt the book but in digital form the pdf is generated with tilted page.

enter image description here

\documentclass{article}
\usepackage[margin=1.0in]{geometry}
% so that i can crop images
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage{epstopdf}
\usepackage{pdflscape}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the image from this link : https://i.imgur.com/CN1gsF4.png
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Required this package for including graphics and landscaping
% \usepackage[paper=portrait,pagesize]{typearea}
% Link to the stack post
% https://tex.stackexchange.com/a/430619/69118

%%%%%%%%%%%%%%%%
% IMAGE TEST ONE
%%%%%%%%%%%%%%%%
\clearpage
A normal text page
\newpage
\begin{landscape}
\begin{figure}[t]
     \includegraphics[width=\linewidth,]{image.png}
\end{figure}
\end{landscape}
\newpage
A normal text page
\end{document}
G. Bay
  • 2,047
  • Thanks, I've tested that and landscape seems to work, though my image doesn't seem to be centred the same as yours ( is your image the same size as mine? Would this make a difference? Are you able to use the image that I created to see if it changes anything please?) Here's the result that I have : https://i.imgur.com/VB4KQzI.png (note that I've removed the page style there). It still seems as though there's quite a bit of dead space, and that the image isn't very central. I don't mind having margins, but to my eye that image looks a bit off. – baxx Jan 03 '19 at 13:04
  • Thats strange, using your image I get this result: https://imgur.com/a/GpZ28eA – G. Bay Jan 03 '19 at 13:19
  • Ah - it seems that the KOMAscript was interfering with things, when removing that it appears to be similar – baxx Jan 03 '19 at 13:25
  • 1
    you don't need the \newpage before and after landscape (as it does \clearpage there anyway.) – David Carlisle Jan 03 '19 at 13:38