`a4paper` documentclass 选项与设置 `\paperheight` 和 `\paperwidth` 的区别

`a4paper` documentclass 选项与设置 `\paperheight` 和 `\paperwidth` 的区别

当我使用代码时

\documentclass[a4paper]{report}

\usepackage{calc}
\usepackage{tikz}

\setlength{\headheight}{10mm}
\setlength{\hoffset}{0mm}
\setlength{\oddsidemargin}{20mm-1in}
%\setlength{\paperheight}{297mm}
%\setlength{\paperwidth}{210mm}
\setlength{\textwidth}{\paperwidth-40mm} % The 40mm corresponds to the 20mm in \oddsidemargin.
\setlength{\topmargin}{20mm-1in-\headheight}
\setlength{\textheight}{\paperheight-\voffset-\topmargin-\headheight-\headsep-\footskip-20mm-1in}

\setlength{\parindent}{0pt}

\begin{document}
    \thispagestyle{empty}

    \tikz [remember picture,overlay]
    \node at ([xshift=-1mm,yshift=2mm]current page.north west) [anchor=north west]
    {
        \begin{tikzpicture}
            \fill[color=black] (0,0) rectangle (\paperwidth,0.1\paperheight);
        \end{tikzpicture}
    };

    \Huge
    Company name\\
    \the\paperheight\\
    \the\paperwidth
\end{document}

黑条的位置很好。但是,如果我使用代码

\documentclass{report}

\usepackage{calc}
\usepackage{tikz}

\setlength{\headheight}{10mm}
\setlength{\hoffset}{0mm}
\setlength{\oddsidemargin}{20mm-1in}
\setlength{\paperheight}{297mm}
\setlength{\paperwidth}{210mm}
\setlength{\textwidth}{\paperwidth-40mm} % The 40mm corresponds to the 20mm in \oddsidemargin.
\setlength{\topmargin}{20mm-1in-\headheight}
\setlength{\textheight}{\paperheight-\voffset-\topmargin-\headheight-\headsep-\footskip-20mm-1in}

\setlength{\parindent}{0pt}

\begin{document}
    \thispagestyle{empty}

    \tikz [remember picture,overlay]
    \node at ([xshift=-1mm,yshift=2mm]current page.north west) [anchor=north west]
    {
        \begin{tikzpicture}
            \fill[color=black] (0,0) rectangle (\paperwidth,0.1\paperheight);
        \end{tikzpicture}
    };

    \Huge
    Company name\\
    \the\paperheight\\
    \the\paperwidth
\end{document}

黑条的位置错误。

期权和\documentclassa4paper

\setlength{\paperheight}{297mm}
\setlength{\paperwidth}{210mm}

在后一种情况下,它是如何破坏黑条的位置的?

相关内容