编辑-zarko 的代码

编辑-zarko 的代码

我在横向模式下包含大图像时遇到问题

这大约是图像渲染的最大尺寸

改变尺寸会导致方向切换

理想情况下,我希望能够在这个横向页面上显示一张大图像,这就是我将页面设计为横向的原因。

另外,重要的是,pdf 中的页面要旋转 90 度(目前就是这种情况),这样当我在屏幕上阅读文档时,就不必倾斜头部来查看横向页面。我希望在任何解决方案中都保留这一点。

以下是示例代码

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

当图像停止托管时,其大小如下:

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

编辑-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}

答案1

  • showframe在文档中,环境中的某些页面landscape无法显示横向页面的正确页面边框
  • 在横向页面中您应该使用图像宽度\linewidth因为\textwidth不会改变
  • 对于横向方向,请只使用一个包,而不是同时使用两个包:lscapepdflscape(两者都会在打印的文档中给出相同的结果,但在屏幕上pdflcsape旋转横向页面以更简单地查看其内容)

以下 mwe,其中我省略了所有与您的问题无关的包。

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

给出

在此处输入图片描述

附录: 现在有了标题和示例图像(您应该使用自己的图像),并删除了以前解决方案中显示文本区域大小的内容。

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

在此处输入图片描述

如您所见,图像位于文本区域的中心。由于现在fbox被删除,图像的宽度仅由以下因素决定:\linewidth

答案2

只要使用就landscape可以了(我做了我自己的图像版本,哈哈)。

该解决方案可确保在打印时/如果打印,页面将照常打印,阅读者必须倾斜书本,但在数字形式下,生成的 pdf 是带有倾斜页面的。

在此处输入图片描述

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

相关内容