有没有一个包可以在页面上画一条对角线-不使用 TikZ

有没有一个包可以在页面上画一条对角线-不使用 TikZ

为了找到右边距,在每页上显示页面的对角线(以及双页的对角线)可能会很有趣,请参见这个问题,这张照片

规范页面构建

可能获得最佳预期结果(仅对角线)。

当然,也可以使用 TikZ 来实现,但由于外部化过程,我更愿意不使用 TikZ。最好的结果是将其放在每个页面上,类似于命令showframe

答案1

在此处输入图片描述

\documentclass[a4paper]{article}
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
\makeatletter

\dimen4=.996264\paperheight
\dimen6=.996264\paperwidth

\pdfliteral page{%
q
n
0  0 m
\strip@pt\dimen6 \space \strip@pt\dimen4 \space l
s
Q}
\begin{document}
zzzz
\end{document}

答案2

这不使用 tikz ;-)

\documentclass[a4paper]{article}
\usepackage{pgf}
\usepackage{eso-pic}

\begin{document}
\AddToShipoutPictureFG{%
\AtPageLowerLeft{%
 \begin{pgfpicture}
  \pgfpathmoveto{\pgfpoint{0mm}{\paperheight}}
  \pgfpathlineto{\pgfpoint{\paperwidth}{0mm}}
  \pgfusepath{stroke}
 \end{pgfpicture}}}%
blub\newpage blub
\end{document}

答案3

您还可以使用包pict2e

\documentclass{article}
\usepackage{eso-pic}
\usepackage{pict2e}

\begin{document}
\AddToShipoutPictureFG{%
  \AtPageLowerLeft{%
    \Line(\LenToUnit{\paperwidth},0)(0,\LenToUnit{\paperheight})%
  }%
}
Text\newpage Text
\end{document}

在此处输入图片描述


在此处输入图片描述

代码:

\documentclass{scrbook}
\newcommand*\snum{10}% number of segments
\KOMAoptions{DIV=\snum}

\usepackage{eso-pic}
\usepackage{pict2e}
\usepackage{xcolor}
\usepackage{ifthen}
\usepackage{calc}

\newcounter{segment}
\newlength\circletextwidth
\setlength\circletextwidth{\paperwidth*\ratio{\paperwidth}{\paperheight}}

\usepackage{blindtext}
\begin{document}
\AddToShipoutPictureFG{%
  \AtPageLowerLeft{%
    \ifodd\value{page}%
      \setcounter{segment}{1}
      \whiledo{\value{segment}<\snum}{%
        \Line
          (\LenToUnit{\value{segment}\paperwidth/\snum},0)%
          (\LenToUnit{\value{segment}\paperwidth/\snum},\LenToUnit{\paperheight})%
        \Line
          (0,\LenToUnit{\value{segment}\paperheight/\snum})%
          (\LenToUnit{\paperwidth},\LenToUnit{\value{segment}\paperheight/\snum})%
        \stepcounter{segment}%
      }%
      \linethickness{2pt}%
      \moveto(\LenToUnit{\paperwidth/\snum},\LenToUnit{2\paperheight/\snum})%
        \lineto(\LenToUnit{\paperwidth-2\paperwidth/\snum},\LenToUnit{2\paperheight/\snum})%
        \lineto(\LenToUnit{\paperwidth-2\paperwidth/\snum},\LenToUnit{\paperheight-\paperheight/\snum})%
        \lineto(\LenToUnit{\paperwidth/\snum},\LenToUnit{\paperheight-\paperheight/\snum})%
        \closepath
        \textcolor{red}{\strokepath}%
      \textcolor{blue}{%
        \Line(\LenToUnit{\paperwidth},0)(0,\LenToUnit{\paperheight})%
        \Line(0,\LenToUnit{.5\paperheight})(\LenToUnit{\paperwidth},\LenToUnit{\paperheight})%
      }
    \else
      \linethickness{2pt}%
      \moveto(\LenToUnit{2\paperwidth/3-2\circletextwidth/3},\LenToUnit{2\paperheight/3-2\paperwidth/3})%
        \lineto(\LenToUnit{2\paperwidth/3+\circletextwidth/3},\LenToUnit{2\paperheight/3-2\paperwidth/3})%
        \lineto(\LenToUnit{2\paperwidth/3+\circletextwidth/3},\LenToUnit{2\paperheight/3+\paperwidth/3})%
        \lineto(\LenToUnit{2\paperwidth/3-2\circletextwidth/3},\LenToUnit{2\paperheight/3+\paperwidth/3})%
        \closepath
        \textcolor{red}{\strokepath}%
        \moveto(\LenToUnit{.5\paperwidth},\LenToUnit{5\paperheight/\snum})%
        \circlearc[1]{\LenToUnit{.5\paperwidth}}{\LenToUnit{2\paperheight/3-\paperwidth/6}}
          {\LenToUnit{.5\paperwidth}}{0}{360}%
        \textcolor{green}{\strokepath}%
      \textcolor{blue}{%
          \Line(0,0)(\LenToUnit{\paperwidth},\LenToUnit{\paperheight})%
          \Line(0,0)(\LenToUnit{\paperwidth},\LenToUnit{.5\paperheight})%
      }%
    \fi
  }%
}
\Blindtext[20]
\end{document}

更改\snum8

\newcommand*\snum{8}

结果是

在此处输入图片描述

答案4

既然您已经有了答案,并提到了您不愿意使用TikZexternal库的潜在问题的原因,我想我会添加一个解决方案来表明这个问题可以解决,以便其他人(像我一样)在某些时候被这个问题绊倒。也许你已经知道了这一点,但仍然不愿意使用TikZ,在这种情况下,我很抱歉打扰你。但以防万一:

您可以通过以下方式禁用或启用文档特定部分或单张图片的外部化:

  • \tikzexternaldisable\tikzexternalenable(第 613 页pgfman.pdf
  • \tikzset{external/export next=false}(或者true,如果您愿意的话)。(第 612 页pgfman.pdf)。我大量使用它来装饰chapterpart正在编写的课程中的页面和一些其他内容,同时仍然external默认启用,它对我来说非常有用。

例子:

\documentclass[a4paper,oneside]{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize %Enable
\pagestyle{empty}

\begin{document}

% This picture will be externalized
\begin{tikzpicture}
    \draw (0,0) circle (4cm);
\end{tikzpicture}

% Disable externalization from here on forward
\tikzexternaldisable

% These two pictures will not be externalized
\begin{tikzpicture}[remember picture,overlay]
    \draw[red] (current page.north east) -- (current page.south west);
\end{tikzpicture}

\begin{tikzpicture}[remember picture,overlay]
    \draw[cyan] (current page.east) -- (current page.west);
\end{tikzpicture}

% Enable externalization from here on forward
\tikzexternalenable

% This picture will be externalized
\begin{tikzpicture}
    \draw (0,0) rectangle (4,2);
\end{tikzpicture}

% Disable Externalize for the next picture only
\tikzset{external/export next=false}%
% This picture will not be externalized
\begin{tikzpicture}[remember picture,overlay]
    \draw[blue] (current page.south east) -- (current page.north west);
\end{tikzpicture}

% This picture will be externalized. Note that we did not
% have to re-enable externalization explicitly.
\begin{tikzpicture}
    \draw[magenta] (5,0) rectangle (11,2);
\end{tikzpicture}
\end{document}

结果: 结果

相关内容