我想创建/绘制文档的首页,因此我想从页面的一角到另一角画一条线。好的,在最终版本中,我想实现一些控制点。但到目前为止,当我使用“页面坐标”而不是点时,我无法使绘图工作……
\documentclass{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{tikz,xcolor}
\usetikzlibrary{shadows}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\coordinate (A) at (current page.north east, current page.north east);
\coordinate (B) at (current page.north, current page.south);
\draw[line width=1.5pt]%, cap=round]
(A) -- (B)
\end{tikzpicture}
\end{document}
答案1
这很好用。你的坐标有误,而且缺少;
。我删除了一些与 mwe 不相关的包
\documentclass{article}
\usepackage{tikz,xcolor}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\coordinate (A) at (current page.north west);
\coordinate (B) at (current page.south east);
\draw[red, very thick]%, cap=round]
(A) -- (B);
\end{tikzpicture}
Test
\end{document}
答案2
不太清楚您要画哪条线:从页面左侧到右侧的一条线?一条对角线?(哪一条?)
此示例使用颜色来区分四种可能性:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\coordinate (A) at (current page.north west);
\coordinate (B) at (current page.south east);
\draw[line width=1.5pt, cap=round, red]
(A) -- (B);
\draw[line width=1.5pt, cap=round, blue]
([yshift=-15pt]current page.north west) -- ([yshift=-15pt]current page.north east);
\draw[line width=1.5pt, cap=round, green]
([yshift=15pt]current page.south west) -- ([yshift=15pt]current page.south east);
\draw[line width=1.5pt, cap=round, magenta]
(current page.south west) -- (current page.north east);
\end{tikzpicture}
\end{document}
这些错误可能是由评论中指出的两个问题引起的:
- 最后的
\draw
命令必须以终止分号结束。 (current page.north,current page.north)
不是位置。它混淆了(<x>,<y>)
语法和(<named coordinate>)
语法。如果您需要类似的东西,您可以说(<named coordinate 1> -| <named coordinate 2>)
哪个将使用 的x
位<named coordinate 1>
和y
的位<named coordinate 2>
。在坐标的情况下,current page
没有太多意义,因为相关点无论如何都是定义的。
但是,为了演示目的:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1.5pt]
(current page.south west) .. controls (10,-10) .. (current page.north -| current page.east);
\end{tikzpicture}
\end{document}