以下是 MWE,用於在頁面左側放置一個黑色矩形,以隱藏印表機在每張紙上留下的黑色標記(?舊墨盒)。
如何使矩形的開口側呈波浪形或絲帶狀,使其看起來具有裝飾性?
\documentclass[a5paper]{article}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\fill[black] (current page.north west) --
($(current page.north west) +(5mm,0)$) --
($(current page.south west) +(5mm,0)$) --
(current page.south west);
\end{tikzpicture}%
}
\begin{document}
\section{A section}
Some text\newpage
\section{Another section}
Some text
\end{document}
答案1
tape
使用以下形狀的另一種選擇shapes.symbols
:
\documentclass[a5paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\node[
tape,
fill=black,
minimum height=2cm,%\paperheight,
minimum width=\paperheight,
rotate=90]
at (current page.west)
{};
\end{tikzpicture}%
}
\begin{document}
\section{A section}
Some text\newpage
\section{Another section}
Some text
\end{document}
改變tape bend height
,你可以產生一些更「波浪形」的東西:
\documentclass[a5paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\node[
tape,
fill=black,
minimum height=2cm,
minimum width=\paperheight,
tape bend height=20pt,
rotate=90]
at (current page.west)
{};
\end{tikzpicture}%
}
\begin{document}
\section{A section}
Some text\newpage
\section{Another section}
Some text
\end{document}
並有coil
裝飾:
\documentclass[a5paper]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\fill[black, decorate, decoration={coil,segment length=30pt}]
(current page.north west) --
([xshift=8mm,yshift=5mm]current page.north west) --
([xshift=8mm,yshift=-5mm]current page.south west) --
(current page.south west);
\end{tikzpicture}%
}
\begin{document}
\section{A section}
Some text.
\newpage
\section{Another section}
Some text.
\end{document}
同樣,使用裝飾屬性可以獲得不同的效果:
\documentclass[a5paper]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\fill[black, decorate, decoration={coil,segment length=90pt,aspect=0}]
(current page.north west) --
([xshift=8mm,yshift=5cm]current page.north west) --
([xshift=8mm,yshift=-5cm]current page.south west) --
(current page.south west);
\end{tikzpicture}%
}
\begin{document}
\section{A section}
Some text.
\newpage
\section{Another section}
Some text.
\end{document}
作為馬克·維布羅已建議在他的評論,如果矩形始終位於左側,則可以透過僅裝飾矩形的右側來提高速度;例如:
\documentclass[a5paper]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\fill[black, decoration={coil,segment length=90pt,aspect=0}]
(current page.north west) --
([xshift=8mm,yshift=5cm]current page.north west)
decorate { --
([xshift=8mm,yshift=-5cm]current page.south west) } --
(current page.south west);
\end{tikzpicture}%
}
\begin{document}
\section{A section}
Some text.
\newpage
\section{Another section}
Some text.
\end{document}
請注意,為此您實際上並不需要該tikznodepages
套件,因為使用的節點已由標準 TikZ 定義。此外,人們還可以不必使用calc
圖書館。
更新:
我看到在你原來的問題您決定改用background
套餐;在這種情況下,要翻譯上面的範例程式碼,您所需要做的就是將環境放置tikzpicture
為contents
鍵的值,如以下範例所示(不需要額外的方塊或另一個額外的內容,tikzpicture
如接受的答案中所示)其他問題;calc
圖書館也不是必需的):
\documentclass[a5paper]{article}
\usepackage{background}
\usetikzlibrary{shapes.symbols}
\backgroundsetup{
angle=0,
scale=1,
opacity=1,
color=black,
contents={
\begin{tikzpicture}[remember picture, overlay]
\node[
tape,
fill=black,
minimum height=2cm,%\paperheight,
minimum width=\paperheight,
rotate=90]
at (current page.west)
{};
\end{tikzpicture}%
}
}
\begin{document}
Some text
\end{document}
答案2
我使用了 TikZ 及其decorations.pathmorphing
庫。我將矩形製作得比上面高,\paperheight
以確保裝飾覆蓋了我們需要的整個區域。
\documentclass[a5paper]{article}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[remember picture, overlay]
\fill[black, decorate, decoration=snake]
(current page.north west) --
($(current page.north west) +(5mm,5mm)$) --
($(current page.south west) +(5mm,-5mm)$) --
(current page.south west);
\end{tikzpicture}}% End of \AddToShipoutPictureBG
\begin{document}
\section{A section}Some text.\newpage
\section{Another section}Some text.
\end{document}