角落之间有多个装饰

角落之间有多个装饰

我想在角落之间的线条中加入一些装饰元素。我正在使用,

\begin{tikzpicture}[every node/.style={inner sep=0pt}]
\node[shift={(1.cm,-1cm)},anchor=north west](CNW)
at (current page.north west) {\pgfornament[width=1.75cm]{61}};
\node[shift={(-1cm,-1cm)},anchor=north east](CNE)
at (current page.north east) {\pgfornament[width=1.75cm,symmetry=v]{61}};
\node[shift={(1cm,1cm)},anchor=south west](CSW)
at (current page.south west) {\pgfornament[width=1.75cm,symmetry=h]{61}};
\node[shift={(-1cm,1cm)},anchor=south east](CSE)
at (current page.south east) {\pgfornament[width=1.75cm,symmetry=c]{61}};
\pgfornamentline{CNW}{CNE}{87}
\pgfornamentline{CSW}{CSE}{87}
\pgfornamentline{CNW}{CSW}{87}
\pgfornamentline{CNE}{CSE}{87}
\end{tikzpicture}%

但我无法定义角落之间的大部分装饰。

从包装描述中可以知道正常定义,

\begin{tikzpicture}[bullet/.style={% circle,draw,fill=black!30,inner sep=2pt}] \draw [help lines,color=black!60] (0,0) grid (5,2); \node[bullet] (A) at (0,0) {}; \node[bullet] (B) at (6,4) {}; \pgfornamentline[color=red]{A}{B}{4}{88} \end{tikzpicture}

但在这里并没有产生预期的结果。

我需要帮助,非常感谢!

为了更好的理解问题,画了一个草图。

在此处输入图片描述

背景选项应该足够了。

到目前为止一切顺利。我尝试用彩色框架对其进行修改。

\documentclass{article}
\usepackage{xcolor} 
\usepackage[object=vectorian]{pgfornament}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{lipsum}

\begin{document}

\backgroundsetup{
scale=1,
opacity=1,
angle=0,
color=black,
contents={%
\begin{tikzpicture}[every node/.style={inner sep=0pt}]
\node[shift={(1cm,-1cm)},anchor=north west](CNW)
at (current page.north west) {\pgfornament[width=1.75cm]{61}};
\node[shift={(-1cm,-1cm)},anchor=north east](CNE)
at (current page.north east) {\pgfornament[width=1.75cm,symmetry=v]{61}};
\node[shift={(1cm,1cm)},anchor=south west](CSW)
at (current page.south west) {\pgfornament[width=1.75cm,symmetry=h]{61}};
\node[shift={(-1cm,1cm)},anchor=south east](CSE)
at (current page.south east) {\pgfornament[width=1.75cm,symmetry=c]{61}}; 
\pgfornamentline{CNW.north east}{CNE.north west}{3}{87}
\pgfornamentline{CSW.south east}{CSE.south west}{3}{87}
\pgfornamentline{CNW.south west}{CSW.north west}{5}{87}
\pgfornamentline{CNE.south east}{CSE.north east}{5}{87} 
\fill[blue] (current page.south west) rectangle ( $ (current page.north west) + (3cm,0) $);
\fill[blue] (current page.south east) rectangle ( $ (current page.north east) + (-3cm,0) $);
\fill[blue] (current page.north west) rectangle ( $ (current page.north east) + (0,-3cm) $);
\fill[blue] (current page.south west) rectangle ( $ (current page.south east) + (0,3cm) $);
\end{tikzpicture}%
}
}


\lipsum[1-20]

\end{document}

但装饰结构被覆盖了。我可以确定相应的级别顺序吗?或者还有其他解决方案吗?如果可能的话,不会失去手动调整彩色框架的能力。

答案1

修正答案

在检查了添加的布局草图和一些其他出现的信息后,就可以找到解决方案的几条途径。

这个问题由多部分组成。

处理第一部分,装饰框架,我们有:

(1)eso-pic封装,并在PDF图片背景层上进行绘制(改编@user11232的解决方案每页角落都有装饰

(2)background包(在 TikZ 上运行),并绘制 tikzpicture(改编自与上述相同链接的 @GonzaloMedina 解决方案)

(3)图片模式,制作一个零宽度图片,并将其放置在页脚中fancyhdr(感谢@BarbaraBeeton 提供 Peter Wilson 2011 TUGboat 文章 v32 p202 的链接)。

至于第二件事,即一条边上应该有多少个装饰符号,除了它是一个判断/基于意见的问题之外,还有一个自动的解决方案(或解决方案)可以进行设计和构建(使用一些尚未指定的美学规则),但由于定义只进行一次,因此手动实现它更加实用(也更简单)。

例如,因为\pgfornamentline可以选择scale=,从而使装饰的数量根据喜好而随意选择,页面长边:短边的比例可以作为指导方针(或不作为):对于 A4 纵向,为 5:3(左:上);或者对于 A5 横向,为 2:3(左:上)。

自动化解决方案听起来很可取,这样的方法将涉及跟踪三个维度,即页面边缘比、装饰比例因子和装饰高度/宽度比,保持其中两个不变,同时改变第三个,但这里不会进一步讨论(至少今晚不会)。


所以:

框架

(1)eso-pic用 封装在背景层上绘图\AddToShipoutPictureBG

定位和布局是手动的。

装饰线是组装好的,因此可以使用单个物品(尽管可以输入一组组装好的元素,并且只能重复一次)。

为了完整性,有关带有框架开/关开关的版本,请参见(1a)。

远视的

平均能量损失

\documentclass[12pt]{article}
\usepackage{pgfornament}
\usepackage{eso-pic}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{lipsum}

\newcommand\AtPageUpperRight[1]{\AtPageUpperLeft{%
 \put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
 }}%
\newcommand\AtPageLowerRight[1]{\AtPageLowerLeft{%
 \put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
 }}%

\newcommand\ornscale{0.42}
\newcommand\ornscalev{0.44}


\newcommand\leavesthree{\pgfornament[scale=\ornscale]{87}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\pgfornament[scale=\ornscale]{87}}

\newcommand\leavesfive{\turnbox{-90}{\pgfornament[scale=\ornscalev]{87}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\pgfornament[scale=\ornscalev]{87}}}



\AddToShipoutPictureBG{%
   \AtPageUpperLeft{\put(25,-50){\textcolor{blue}{\pgfornament[width=1.75cm]{61}}}}
   \AtPageUpperRight{\put(-75,-50){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=v]{61}}}}
   \AtPageLowerLeft{\put(25,50){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=h]{61}}}}
   \AtPageLowerRight{\put(-75,50){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=c]{61}}}}
   \AtPageUpperLeft{\put(78,-25){\leavesthree}}%top border
   \AtPageLowerLeft{\put(78,27){\leavesthree}}%bottom
   \AtPageUpperLeft{\put(25,-78){\leavesfive}}%left side   
   \AtPageUpperRight{\put(-25,-78){\leavesfive}}%right side
   }
   
   

\begin{document}
\lipsum[1-40]
\end{document}

(1a)

为了使框架可打开/关闭,请创建一个新的 IF 变量:

\newif{\ifbgoff}
\bgofftrue

其中(在这种方法中) true 表示“无框架”(如“背景关闭”)。

将 if 条件添加到\AddToShipoutPictureBG命令中,如下所示:

\AddToShipoutPictureBG{%
 \ifbgoff\else  *<existing code>* \fi}

使用方法:结合或同等功能打开(用\bgofffalse)/关闭(用)框架。\bgofftrue\newpage

\begin{document}
\section{Off}
\lipsum[1-15]
\bgofffalse
\section{On}
\lipsum[1-15]

\newpage
\bgofftrue
\section{Off Again}
\lipsum[1-8]

\newpage\bgofffalse
\section{On Again}
\lipsum[1-15]


\newpage
\bgofftrue
\section{And Off Once More}
\lipsum[1-8]


\end{document}

完整 MWE:

\documentclass[12pt]{article}
\usepackage{pgfornament}
\usepackage{eso-pic}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{lipsum}

\newcommand\AtPageUpperRight[1]{\AtPageUpperLeft{%
 \put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
 }}%
\newcommand\AtPageLowerRight[1]{\AtPageLowerLeft{%
 \put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
 }}%

\newcommand\ornscale{0.42}
\newcommand\ornscalev{0.44}


\newcommand\leavesthree{\pgfornament[scale=\ornscale]{87}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\pgfornament[scale=\ornscale]{87}}

\newcommand\leavesfive{\turnbox{-90}{\pgfornament[scale=\ornscalev]{87}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\pgfornament[scale=\ornscalev]{87}}}

\newif{\ifbgoff}
\bgofftrue

\AddToShipoutPictureBG{%
 \ifbgoff\else  \AtPageUpperLeft{\put(25,-50){\textcolor{blue}{\pgfornament[width=1.75cm]{61}}}}
   \AtPageUpperRight{\put(-75,-50){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=v]{61}}}}
   \AtPageLowerLeft{\put(25,50){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=h]{61}}}}
   \AtPageLowerRight{\put(-75,50){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=c]{61}}}}
   \AtPageUpperLeft{\put(78,-25){\leavesthree}}%top border
   \AtPageLowerLeft{\put(78,27){\leavesthree}}%bottom
   \AtPageUpperLeft{\put(25,-78){\leavesfive}}%left side   
   \AtPageUpperRight{\put(-25,-78){\leavesfive}}%right side
   \fi}
   
   

\begin{document}
\section{Off}
\lipsum[1-15]
\bgofffalse
\section{On}
\lipsum[1-15]

\newpage
\bgofftrue
\section{Off Again}
\lipsum[1-8]

\newpage\bgofffalse
\section{On Again}
\lipsum[1-15]


\newpage
\bgofftrue
\section{And Off Once More}
\lipsum[1-8]


\end{document}

(2)background在命令中添加tikzpicture包\backgroundsetup

使用 TikZ 定位元素变得更加容易。

装饰线是一个单位。

可以在文档中以页面为基础打开/关闭或更改背景。

背景

平均能量损失

\documentclass[12pt]{article}
\usepackage{background}
\usepackage{pgfornament}
\usepackage{lipsum}
\usetikzlibrary{calc}

\backgroundsetup{
scale=1,
opacity=1,
angle=0,
color=black,
contents={%
\begin{tikzpicture}[every node/.style={inner sep=0pt}]
\node[shift={(1cm,-1cm)},anchor=north west](CNW)
at (current page.north west) {\pgfornament[width=1.75cm]{61}};
\node[shift={(-1cm,-1cm)},anchor=north east](CNE)
at (current page.north east) {\pgfornament[width=1.75cm,symmetry=v]{61}};
\node[shift={(1cm,1cm)},anchor=south west](CSW)
at (current page.south west) {\pgfornament[width=1.75cm,symmetry=h]{61}};
\node[shift={(-1cm,1cm)},anchor=south east](CSE)
at (current page.south east) {\pgfornament[width=1.75cm,symmetry=c]{61}};
\pgfornamentline{CNW.north east}{CNE.north west}{3}{87}
\pgfornamentline{CSW.south east}{CSE.south west}{3}{87}
\pgfornamentline{CNW.south west}{CSW.north west}{5}{87}
\pgfornamentline{CNE.south east}{CSE.south east}{5}{87}
\end{tikzpicture}%
  }
}

\begin{document}
\lipsum[1-40]
\end{document}

(3)页脚(或页眉,如果需要)中的图片模式零宽度图片

由于使用了图片模式,因此这里定位是手动的。

可以使用fancyhdr包命令来修改页脚和页眉(以及相关的页面样式)。

零宽度图片

平均能量损失

\documentclass[12pt]{article}
\usepackage{pgfornament}
%\usepackage{eso-pic}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lipsum}


\newcommand\ornscale{0.39}
\newcommand\ornscalev{0.45}


\newcommand\leavesthree{\pgfornament[scale=\ornscale]{87}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\pgfornament[scale=\ornscale]{87}}

\newcommand\leavesfive{\turnbox{-90}{\pgfornament[scale=\ornscalev]{87}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\textcolor{red}{\pgfornament[scale=\ornscale]{87}}\pgfornament[scale=\ornscalev]{87}}}

%\pgfornament[width=2cm]{3}

\newcommand*{\upit}[2]{\raisebox{#1}{#2}}\newcommand*{\rotpi}[1]{\rotatebox{180}{#1}}\newcommand*{\rotrt}[1]{\rotatebox{90}{#1}}\newcommand*{\rotlft}[1]{\rotatebox{-90}{#1}}

%%% draws a (page) frame
\newcommand*{\goddfoot}{\begin{picture}(0,0)
%\wb{10pt}{10pt}
\put(-70,-50){% change these to move the frame
\begin{picture}(0,0)
\multiput(52,0)(0,0){1}{\leavesthree}   % bottom
\multiput(5,669)(0,0){1}{\leavesfive}   % left
\multiput(530,669)(0,0){1}{\leavesfive}  % right
\multiput(52,718)(0,0){1}{\leavesthree} % top
\put(0,700){\textcolor{blue}{\pgfornament[width=1.75cm]{61}}}%TL
\put(485,700){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=v]{61}}}%TR
\put(0,20){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=h]{61}}}%BL
\put(485,20){\textcolor{blue}{\pgfornament[width=1.75cm,symmetry=c]{61}}}%BR
\end{picture}}
\end{picture}}
\let\gevenfoot\goddfoot

\fancyfoot[L]{\goddfoot}
   

\begin{document}
\lipsum[1-40]
\end{document}

原始答案

您需要提供一个最小工作示例,以便人们可以测试他们的答案而不必猜测任何事情;并且还可以使用选项remember picture,overlay(如手册所述)。

我不确定你打算用锚来做什么。

此 MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfornament}

\begin{document}
\begin{tikzpicture}[remember picture,overlay,every node/.style={inner sep=0pt}]
\node [shift={(1cm,-1cm)},blue,scale=2] (CNW)
at (current page.north west) {\pgfornament[height=1cm,width=1cm]{61}};
\node [shift={(-1cm,-1cm)},blue,scale=2] (CNE)
at (current page.north east) {\pgfornament[height=1cm,width=1cm,symmetry=v]{61}};
\node [shift={(1cm,1cm)},blue,scale=2] (CSW)
at (current page.south west) {\pgfornament[height=1cm,width=1cm,symmetry=h]{61}};
\node [shift={(-1cm,1cm)},blue,scale=2] (CSE)
at (current page.south east) {\pgfornament[height=1cm,width=1cm,symmetry=c]{61}};
\pgfornamentline[color=brown]{CNW}{CNE}{2}{87}
\pgfornamentline{CSW}{CSE}{2}{87}
\pgfornamentline{CNW}{CSW}{3}{87}
\pgfornamentline{CNE}{CSE}{3}{87}
\end{tikzpicture}%

产生这个:

装饰品


添加

在 TikZ 中,有多种方法可以实现相同的效果。

如果我正确理解了评论中的说法,如果目标是在页面的各个角落之间、从一个角到另一个角画出装饰线,并且线的中心位于页面边缘,那么一种方法是——在页面的各个角落之间画出装饰线:

\pgfornamentline[color=brown]{current page.north west}{current page.north east}{2}{87}
\pgfornamentline{current page.south west}{current page.south east}{2}{87}
\pgfornamentline{current page.north west}{current page.south west}{3}{87}
\pgfornamentline{current page.north east}{current page.south east}{3}{87}

为了避免被覆盖,(一种方法是)可以使用选项将角落装饰物推开anchor=

边缘装饰

微波辐射计

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfornament}

\begin{document}
\begin{tikzpicture}[remember picture,overlay,every node/.style={inner sep=0pt}]
\node [shift={(1cm,-1cm)},blue,scale=2,anchor=north west] (CNW)
at (current page.north west) {\pgfornament[height=1cm,width=1cm]{61}};
\node [shift={(-1cm,-1cm)},blue,scale=2,anchor=north east] (CNE)
at (current page.north east) {\pgfornament[height=1cm,width=1cm,symmetry=v]{61}};
\node [shift={(1cm,1cm)},blue,scale=2,anchor=south west] (CSW)
at (current page.south west) {\pgfornament[height=1cm,width=1cm,symmetry=h]{61}};
\node [shift={(-1cm,1cm)},blue,scale=2,anchor=south east] (CSE)
at (current page.south east) {\pgfornament[height=1cm,width=1cm,symmetry=c]{61}};
%\pgfornamentline[color=brown]{CNW}{CNE}{2}{87}
%\pgfornamentline{CSW}{CSE}{2}{87}
%\pgfornamentline{CNW}{CSW}{3}{87}
%\pgfornamentline{CNE}{CSE}{3}{87}
\pgfornamentline[color=brown]{current page.north west}{current page.north east}{2}{87}
\pgfornamentline{current page.south west}{current page.south east}{2}{87}
\pgfornamentline{current page.north west}{current page.south west}{3}{87}
\pgfornamentline{current page.north east}{current page.south east}{3}{87}
\end{tikzpicture}%

%\begin{tikzpicture}[bullet/.style={% 
%circle,draw,fill=black!30,inner sep=2pt}] 
%\draw [help lines,color=black!60] (0,0) grid (5,2); 
%\node[bullet] (A) at (0,0) {}; \node[bullet] (B) at (6,4) {}; 
%\pgfornamentline[color=red]{A}{B}{4}{88} 
%\end{tikzpicture}
\end{document}

相关内容