使用图片作为整个文档的页面边框

使用图片作为整个文档的页面边框

我有一个 LaTeX 文档,并且得到了一个 PNG 文件,该文件由页面边框和中间的一个大透明部分组成。

是否可以使用 LaTeX 将该图像添加到每个页面,并将实际内容放在透明部分;或者我必须使用 LaTeX 创建 PDF,然后以其他方式手动添加边框?

答案1

一个选择是使用background包中放置图像作为背景图像;geometry包可用于调整文本区域。举个小例子:

\documentclass{article}
\usepackage[tmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm,bmargin=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{background}
\usepackage{fourier}
\usepackage{lipsum}

\backgroundsetup{scale=1,angle=0,opacity=1,contents={\includegraphics[scale=1]{border}}}

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

生成的文档第一页的图像:

在此处输入图片描述

这是我用来制作边框的代码:

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

\definecolor{mycolor}{cmyk}{0,0,0.1,0}

\pagestyle{empty}
\begin{document}
\color{mycolor}
\begin{tikzpicture}[remember picture,overlay] 
\coordinate (a) at ( $ (current page.north west) +  (1cm,-1cm)$); 
\coordinate (b) at ( $ (current page.south west) +  (1cm,1cm)$); 
\coordinate (c) at ( $ (current page.south east) +  (-1cm,1cm)$); 
\coordinate (d) at ( $ (current page.north east) +  (-1cm,-1cm)$); 
\fill[Maroon] (current page.south west) rectangle ( $ (current page.north west) + (2cm,0) $);
\fill[Maroon] (current page.south east) rectangle ( $ (current page.north east) + (-2cm,0) $);
\fill[Maroon] (current page.north west) rectangle ( $ (current page.north east) + (0,-2cm) $);
\fill[Maroon] (current page.south west) rectangle ( $ (current page.south east) + (0,2cm) $);
\pgfornamenthline{a}{d}{north}{87}
\pgfornamenthline{b}{c}{south}{87}
\pgfornamentvline{a}{b}{west}{87}
\pgfornamentvline{c}{d}{east}{87} 
\end{tikzpicture}
\end{document}

相关内容