包含略大于线宽的图形

包含略大于线宽的图形

我正在尝试加载适合和的图形\textwidth\textheight即除顶部、底部、左侧和右侧边距之外的整个页面。但是,当我将图形与\textwidth\textheight参数一起包含时,它不适合,并且被推到下一页。

为什么会发生这种情况?是否可以更改页面的几何形状,以便命令

\inlcudegraphics[width=\linewidth, height=\textheight]{filename}

作品?

附言:我并不是在寻找这样的解决方法

\inlcudegraphics[width=.9\linewidth, height=.9\textheight]{filename}

我想选择边距和图片来精确使用该空间。

当前 MWE

\documentclass[10pt,a4paper]{article}
\usepackage[left=1.00cm, right=1.00cm, top=1.00cm, bottom=1.00cm,marginparsep=0cm, showframe]{geometry}
\usepackage{graphicx}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}
\includegraphics[width=\linewidth, height=\textheight, trim={0 0 0 0}]{filename}
\end{document}

答案1

总是会在第一页放一张整页图片有问题。其他页面都可以。

\documentclass[10pt,a4paper]{article}
\usepackage[left=1.00cm, right=1.00cm, top=1.00cm, bottom=1.00cm,marginparsep=0cm, showframe]{geometry}
\usepackage{graphicx}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}
\vspace*{\fill}\smash{%
\includegraphics[width=\linewidth, height=\textheight, trim={0 0 0 0}]{example-image}}
\end{document}

答案2

像这样

\documentclass[10pt,a4paper]{article}
\usepackage[left=1cm,
            right=1cm,
            top=1cm,
            bottom=1cm,
            marginparsep=0cm,
            showframe
            ]{geometry}
\usepackage{graphicx}
\pagestyle{empty}
%\setlength{\parindent}{0pt}

\makeatother
\begin{document}
% this only to gather some info, not needed for graphics inclusion
\setbox0\hbox{\includegraphics[width=\linewidth,
                               height=\textheight]{example-image-a}}%
\typeout{\number\wd0, \number\ht0 \space(box)}
\typeout{\number\linewidth, \number\textheight\space(actual text area dimensions)}
% actual graphics inclusion
\vbox to \textheight{\hsize\linewidth
                     \vss
                     \noindent
                     \makebox[\linewidth]{%
                     \includegraphics[width=\linewidth,
                                      height=\textheight]{example-image-a}%
                     }%
                     \vss}


\end{document}

日志包含

35430201, 51656780 (box)
35428918, 51651632 (actual text area dimensions)

在此处输入图片描述

注意:我也尝试\Gscale@div用更精确的替换:

\documentclass[10pt,a4paper]{article}
\usepackage[left=1cm,
            right=1cm,
            top=1cm,
            bottom=1cm,
            marginparsep=0cm,
            showframe
            ]{geometry}
\usepackage{graphicx}
\pagestyle{empty}
%\setlength{\parindent}{0pt}

\makeatletter
% https://tex.stackexchange.com/a/383700/4686
\newcommand\SetToRatio[3]{% sets #1 to be the ratio #2/#3, where #2 and #3 
    % are lengths (registers or expressions).
    % The ratio #2/#3 should evaluate to less than 16384 in absolute value to 
    % avoid arithmetic overflow. It will be computed as fixed point
    % number with about 4 or 5 digits after decimal mark.
    \edef #1%
        {\strip@pt\dimexpr
         \numexpr\dimexpr#2\relax*65536/\dimexpr#3\relax\relax sp\relax}%
}

\let\Gscale@div\SetToRatio
\makeatother
\begin{document}

\setbox0\hbox{\includegraphics[width=\linewidth,
                               height=\textheight]{example-image-a}}%
\typeout{\number\wd0, \number\ht0 \space(box)}
\typeout{\number\linewidth, \number\textheight\space(actual text area dimensions)}

\vbox to \textheight{\hsize\linewidth
                     \vss
                     \noindent
                     \makebox[\linewidth]{%
                     \includegraphics[width=\linewidth,
                                      height=\textheight]{example-image-a}%
                     }%
                     \vss}


\end{document}

但日志文件包含

35428916, 51651721 (box)
35428918, 51651632 (actual text area dimensions)

\textheight因此,尽管宽度更精确,但高度仍然大于。并且未换行的图像仍被推送到下一页。

我也尝试\divdefhttps://tex.stackexchange.com/a/383700/4686它给出的结果与使用上述 e-TeX 依赖方法的结果完全相同。

注意,然后你可以使用

\noindent\includegraphics[width=\linewidth,
                          height=\dimexpr\textheight-50sp\relax]{example-image-a}

使用未修补的 graphicx,它可以工作:(65536sp = 1pt)

\noindent\includegraphics[width=\linewidth,
                          height=\dimexpr\textheight-5150sp\relax]{example-image-a}

答案3

这有用吗?

\documentclass[10pt,a4paper]{article}
\usepackage[left=1.00cm, right=1.00cm, top=1.00cm, bottom=1.00cm,marginparsep=0cm, showframe]{geometry}
\usepackage{graphicx}
\usepackage{mwe}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\begin{document}
\begin{figure}
 \includegraphics[width=\linewidth, height=\textheight, trim={0 0 0 0}]{example-image-a}
\end{figure}
\end{document}

在此处输入图片描述

相关内容