然而,我发现很难理解 tikz 使用的坐标系......现在我发现线条走向了错误的方向。
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage[left=5.2cm,top=2cm,right=1.5cm,bottom=2cm,verbose,nohead,nofoot]{geometry}
\usepackage{etoolbox}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\path (2cm,27cm) node (p2) {};
\path (2cm,1cm) node (p1) {};
\draw (p1) to (p2);
\end{tikzpicture}
\end{document}
谢谢!
编辑 我确实设法把某些东西敲定成形,但我认为下面的答案可能更合理......特别是当我注意到我的 A4 页面显然有 30 厘米高时!
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage[left=2cm,top=1cm,right=1cm,bottom=1cm,verbose,nohead,nofoot]{geometry}
\usepackage{etoolbox}
\usepackage{xcolor}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\node [shift={(-21 cm,-30cm)}] at (current page.north east)
{%
\begin{tikzpicture}[remember picture, overlay]
\path (2cm,1cm) node (p1) {};
\path (2cm,30cm) node (p2) {};
\path (0,1cm) node (p3) {};
\path (21cm,1cm) node (p4) {};
\path (20cm,1cm) node (p5) {};
\path (20cm,30cm) node (p6) {};
\path (2cm,26cm) node (p7) {};
\path (20cm,26cm) node (p8) {};
\path (20cm,15cm) node (p9) {};
\path (21cm,15cm) node (p10) {};
\path (11cm,26cm) node (p11) {};
\path (11cm,30cm) node (p12) {};
\path (2cm,27cm) node (p13) {};
\path (11cm,27cm) node (p14) {};
\path (2cm,30cm) node (p15) {};
\draw (p1.center) to (p2.center);
\draw (p3.center) to (p4.center);
\draw (p5.center) to (p6.center);
\draw (p7.center) to (p8.center);
\draw (p9.center) to (p10.center);
\draw (p11.center) to (p12.center);
\draw (p13.center) to (p14.center);
%draw hole punches to ISO838
\draw (1.2cm,11) circle (0.6cm);
\draw (1.2cm,19) circle (0.6cm);
\draw (2.5cm,26.5cm) node[anchor=west,draw=none]{\Large{Poisons Case Record}};
\draw (20.5cm,14.5cm) node[anchor=west, rotate=270 ,draw=none]{\Large{Poisons Case Record}};
%if we have the aust coloured system then this one is it
%\draw[blue] (20cm,15cm)rectangle (21cm,30cm);
\end{tikzpicture}
};
\end{tikzpicture}
\end{document}
答案1
您可以尝试通过相对于页面角落进行定位。以下是示例
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage[left=5.2cm,top=2cm,right=1.5cm,bottom=2cm,verbose,nohead,nofoot]{geometry}
\usepackage{etoolbox}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\coordinate (BL) at (current page.south west); % bottom left
\coordinate (TR) at (current page.north east); % top right
\fill[yellow!20] (BL) rectangle ++(2, \paperheight) node[pos = 0.5, rotate = 90, black]{Some text};
\fill[blue!20] (TR) rectangle ++(-3, -\paperheight) node[pos = 0.5, rotate = 90, black]{Some text};
\end{tikzpicture}
\end{document}
答案2
以下是使用图层页面样式的另一个建议:
\documentclass[a4paper,12pt]{article}
\newlength\topboxheight
\setlength\topboxheight{6\baselineskip}
\usepackage[hmargin=2cm,bottom=1cm,top=\dimexpr1cm + \topboxheight\relax,verbose,nohead,nofoot]{geometry}
\usepackage{graphicx}
\usepackage{scrlayer}
\DeclareNewPageStyleByLayers{form}{form.lines,form.right.lower,form.text.top.left,form.text.top.right}
\DeclareNewLayer[
background,
textarea,
addvoffset=-\topboxheight,
addheight=\topboxheight,
mode=picture,
contents={%
\put(\LenToUnit{-\layerxoffset},0){\line(1,0){\LenToUnit{\paperwidth}}}%
\putUL{\line(1,0){\LenToUnit{\dimexpr\layerwidth+\layerxoffset\relax}}}%
\putLL{\line(0,1){\LenToUnit{\dimexpr\layerheight+\layeryoffset\relax}}}%
\putLR{\line(0,1){\LenToUnit{\layerheight}}}%
\put(\LenToUnit{\layerwidth},\LenToUnit{.5\layerheight}){%
\line(1,0){\LenToUnit{\dimexpr\paperwidth-\layerwidth-\layerxoffset}}}%
\put(\LenToUnit{.5\layerwidth},\LenToUnit{\layerheight}){%
\line(0,-1){\LenToUnit{\topboxheight}}}
\put(0,\LenToUnit{\dimexpr\layerheight-\topboxheight\relax}){%
\line(1,0){\LenToUnit{\layerwidth}}}
\put(\LenToUnit{-.8cm},\LenToUnit{\dimexpr\layerheight-19cm\relax}){%
\circle{\LenToUnit{1.2cm}}}
\put(\LenToUnit{-.8cm},\LenToUnit{\dimexpr\layerheight-11cm\relax}){%
\circle{\LenToUnit{1.2cm}}}
}
]{form.lines}
\DeclareNewLayer[
foreground,
rightmargin,
voffset=.5\paperheight,
height=.5\paperheight,
contents=\hfill\rotatebox{270}{\Large Poissons Case Record}\hfill
]{form.right.lower}
\makeatletter
\DeclareNewLayer[
foreground,
textarea,
addvoffset=-\topboxheight,
height=\topboxheight,
contents={%
\parbox[t][\layerheight]{.5\layerwidth}{%
\begin{tabular}{p{\dimexpr\linewidth-\tabcolsep}@{}}
Hospital name\hfill\includegraphics[height=2\baselineskip]{example-image}\\[.5\baselineskip]
Patient:\enskip\@patientname\\
\@otherdetails
\end{tabular}%
}%
}
]{form.text.top.left}
\DeclareNewLayer[
clone=form.text.top.left,
addhoffset=.5\textwidth,
contents={%
\parbox[t][\layerheight]{.5\layerwidth}{%
\begin{tabular}{p{\dimexpr\linewidth-\tabcolsep}@{}}
Medical record number:\enskip\@medicalrecordnumber\rule{0pt}{2\baselineskip}\\[.5\baselineskip]
Ward:\enskip\@ward
\end{tabular}%
}%
}
]{form.text.top.right}
\newcommand\@patientname{}
\newcommand\patientname[1]{\edef\@patientname{#1}}
\newcommand\@otherdetails{}
\newcommand\otherdetails[1]{\edef\@otherdetails{#1}}
\newcommand\@medicalrecordnumber{}
\newcommand\medicalrecordnumber[1]{\edef\@medicalrecordnumber{#1}}
\newcommand\@ward{}
\newcommand\ward[1]{\edef\@ward{#1}}
\makeatother
\usepackage{lipsum}%dummy text
\begin{document}
\patientname{Bimbo Bull}
\otherdetails{Some text as other information.}
\medicalrecordnumber{123456789}
\ward{WWW}
\thispagestyle{form}
\lipsum
\end{document}