I want to create the page border like the image in the attachment but I don't know how to do that? Please help me and thank you.
- 237,551
- 119
2 Answers
If the given border is only an example to show what you want to do you could use the package pgfornament.
Using scrlayer-scrpage the border could be added to one or more layer page styles.
\documentclass{article}
\usepackage[%
margin=4cm
%,showframe% to show the page layout
]{geometry}
\usepackage[object=vectorian]{pgfornament}
\newcommand\om{5mm}% ornament margin
\newcommand\ow{5cm}% ornament width
\newcommand\ols{5.5mm}% ornament line shift
\newcommand\on{63}% ornament number
\colorlet{bordercolor}{purple}
\tikzset{
ol/.style={line width=1mm,dotted}% style for the lines
}
% define the border and save it in a box
\newsavebox\border
\sbox\border{%
\tikz[color=bordercolor]{
\useasboundingbox(0,0)rectangle(\paperwidth,-\paperheight);
\foreach[count=\i]\a/\p/\s in {%
north west/{\om,-\om}/none,
north east/{{\paperwidth-\om},-\om}/v,
south east/{{\paperwidth-\om},{-\paperheight+\om}}/c,%
south west/{\om,{-\paperheight+\om}}/h%
}\nodeanchor=\a at (\p){\pgfornament[width=\ow,symmetry=\s]{\on}};
\begin{scope}[ol]
\draw([yshift=-\ols]n1.north east)--([yshift=-\ols]n2.north west);
\draw([xshift=-\ols]n2.south east)--([xshift=-\ols]n3.north east);
\draw([yshift=\ols]n3.south west)--([yshift=\ols]n4.south east);
\draw([xshift=\ols]n4.north west)--([xshift=\ols]n1.south west);
\end{scope}
}%
}
\usepackage[manualmark]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot*{\pagemark}
% define a switch to enable and disable the border
\newif\ifBorder
% define a new layer
\DeclareNewLayer[{%
background,
page,
contents={\ifBorder\usebox\border\fi}
}]{border.bg}
% add the border layer to all layer page styles (scrheadings, plain, empty, ...) ...
\AddLayersAtBeginOfPageStyle{@everystyle@}{border.bg}
\usepackage{blindtext}% dummy text
\begin{document}
\Bordertrue% enable the border
\Blindtext[10]
\clearpage
\Borderfalse% disable the border
\Blindtext[10]
\end{document}

With scrlayer-scrpage it is also possible to disable the border on selected page styles:
\documentclass{article}
\usepackage[%
margin=4cm
%,showframe% to show the page layout
]{geometry}
\usepackage[object=vectorian]{pgfornament}
\newcommand\om{5mm}% ornament margin
\newcommand\ow{5cm}% ornament width
\newcommand\ols{5.5mm}% ornament line shift
\newcommand\on{63}% ornament number
\colorlet{bordercolor}{purple}
\tikzset{
ol/.style={line width=1mm,dotted}% style for the lines
}
% define the border and save it in a box
\newsavebox\border
\sbox\border{%
\tikz[color=bordercolor]{
\useasboundingbox(0,0)rectangle(\paperwidth,-\paperheight);
\foreach[count=\i]\a/\p/\s in {%
north west/{\om,-\om}/none,
north east/{{\paperwidth-\om},-\om}/v,
south east/{{\paperwidth-\om},{-\paperheight+\om}}/c,%
south west/{\om,{-\paperheight+\om}}/h%
}\nodeanchor=\a at (\p){\pgfornament[width=\ow,symmetry=\s]{\on}};
\begin{scope}[ol]
\draw([yshift=-\ols]n1.north east)--([yshift=-\ols]n2.north west);
\draw([xshift=-\ols]n2.south east)--([xshift=-\ols]n3.north east);
\draw([yshift=\ols]n3.south west)--([yshift=\ols]n4.south east);
\draw([xshift=\ols]n4.north west)--([xshift=\ols]n1.south west);
\end{scope}
}%
}
\usepackage[manualmark]{scrlayer-scrpage}
\clearpairofpagestyles
\addtokomafont{pagehead}{\color{blue!50!green!80!black}\large}
\chead{The current page style is \toplevelpagestyle{} \ifstr{\toplevelpagestyle}{\currentpagestyle}{}{as alias for \currentpagestyle}.}
\cfoot{\pagemark}
% define a switch to enable and disable the border
\newif\ifBorder
% define a new layer
\DeclareNewLayer[{%
background,
page,
contents={\ifBorder\usebox\border\fi}
}]{border.bg}
% add the border layer to all layer page styles (scrheadings, plain, empty, ...) ...
\AddLayersAtBeginOfPageStyle{@everystyle@}{border.bg}
% but no border on empty pages
\AddToLayerPageStyleOptions{empty}{oninit=\Borderfalse}
\usepackage{blindtext}% dummy text
\begin{document}
\Bordertrue
\Blindtext
\clearpage
\pagestyle{empty}
\Blindtext[10]
\clearpage
\pagestyle{plain}
\Blindtext
\end{document}
The pagestyle on page 1 is scrheadings and on page 4 plain both with border. But pages 2 and 3 use pagestyle empty and there is no border because of
\AddToLayerPageStyleOptions{empty}{oninit=\Borderfalse}

- 85,675
-
Oh, I'm very glad to thank esdd to help me another way to create nice border page, thank esdd. – newstar May 21 '15 at 13:07
-
1@richard Thanks for the hint. I have updated my answer, because package
pgfornamentis on CTAN and also part of MiKTeX and TL. – esdd May 06 '22 at 11:56
Saving your border as ZmI9O.jpg, and employing my answer referenced in my comment, I only had to adjust the filename, paper (aspect), scale, and the offset to create a letter using your border.
Upon EDIT, I used the geometry package to show how to set the margin to fit the border, and changed the hook from "Thispage" to "Everypage", so that the border would continue on subsequent pages.
\documentclass[letter]{article}
\usepackage{everypage}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage[margin=1.5in]{geometry}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
\AddEverypageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
\raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\begin{document}
\atxy{-1.65in}{11.4in}{\includegraphics[scale=1.42]{ZmI9O}}
\lipsum[1-7]
\end{document}

- 237,551
-
I have followed your example, but the image of page border seem slightly blurred image, how can I resolve it? Here the image of this: http://i.stack.imgur.com/8J0RK.png – newstar May 20 '15 at 01:26
-
@datanhlg It is blurred because the original shown in your question is likewise blurred (and I copied that for use). Presumably, you have access to a high-resolution version of it somewhere, and you should use that version. Of course, when you do, you will likely have to adjust the
scale=value and the\atxycoordinates. – Steven B. Segletes May 20 '15 at 01:30 -
Oh, thank for your help, it's very useful to me because I'm just using LaTex, thank again Steven B. Segletes. – newstar May 20 '15 at 01:34
-
@datanhlg If you are using "plain" LaTeX, the image that comprises the border will have to be an encapsulated postscript (EPS) file. If you are using pdflatex or similar, the border image can be a PDF, JPG, PNG, etc (many formats except EPS). Best wishes! – Steven B. Segletes May 20 '15 at 01:39
-
tikz, this answer of mine, http://tex.stackexchange.com/questions/208977/how-do-i-add-beautiful-borders-to-the-title-page/209017#209017, shows how to employ ready-made borders that you may find on the internet. – Steven B. Segletes May 20 '15 at 01:12