2

I like to put frame around each page. Only around the text area of the page. Not including the header and footer.

I am also using fancyhdr. After some struggle, I got the following.

But the frame around the text area is too close to the text itself. I am not sure how to add extra space. Should I make textwidth itself smaller? Or make frame wider? And how to do these things. This is what I have now:

enter image description here

I am using Tikz code I found on the net and made small modification to change thickness and color of the frame. Here is MWE

\documentclass[12pt,oneside]{book}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%% fancyhdr

\usepackage{textcase} \usepackage{fancyhdr} \fancyhead{} % clear all header fields \fancyfoot{} % clear all footer fields

\renewcommand{\headrulewidth}{0pt}% default is 0pt \fancyhead[R]{{\footnotesize\scshape\thepage}}

\fancyhead[L]{\leftmark} \fancyfoot[L]{\nouppercase{\rightmark}} \renewcommand{\footrulewidth}{0pt}% default is 0pt
\pagestyle{fancy}

\usepackage{tikzpagenodes} \usepackage[contents={}]{background} \AddEverypageHook{% \tikz[remember picture,overlay]{ \draw[line width=.5pt,rounded corners,gray] (current page text area.north east) -- (current page text area.north west) -- (current page text area.south west) -- (current page text area.south east) -- cycle; } }

\setcounter{tocdepth}{1} % 4 for main TOC must be in preamble \setcounter{secnumdepth}{5}

\begin{document} \title{My most important work\vspace{-8pt}} \author{me} \date{\today} \maketitle
\tableofcontents \blinddocument \end{document}

Need something similar to Vector frame on all pages

enter image description here

But I could not make the above work with fancyhdr , it messed it up. Will keep trying.

The space buffer does not have to be too large. I just do not like the text touching the frame, makes it hard to read.

I basically need something like this:

enter image description here

using TL 2023 with lualatex

Nasser
  • 20,220

1 Answers1

2

How about using the fit library and just a node?

\usetikzlibrary{fit}
\AddEverypageHook{%
  \tikz[remember picture,overlay]{
    \node [fit=(current page text area),draw,inner sep=10pt] {};
  }
}

You can modify inner sep as desired.

framed page with breathing space

showing header as well as footer outside frame

\documentclass[12pt,oneside]{book}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{blindtext}
%%%%%%%%%%%%%%%%%%%%%%%%% fancyhdr

\usepackage{textcase} \usepackage{fancyhdr} \fancyhead{} % clear all header fields \fancyfoot{} % clear all footer fields

\renewcommand{\headrulewidth}{0pt}% default is 0pt \fancyhead[R]{{\footnotesize\scshape\thepage}}

\fancyhead[L]{\leftmark} \fancyfoot[L]{\nouppercase{\rightmark}} \renewcommand{\footrulewidth}{0pt}% default is 0pt
\pagestyle{fancy}

\usepackage{tikzpagenodes} \usepackage[contents={}]{background} \usetikzlibrary{fit} \AddEverypageHook{% \tikz[remember picture,overlay]{ \node [fit=(current page text area),draw,inner sep=10pt] {}; } }

\setcounter{tocdepth}{1} % 4 for main TOC must be in preamble \setcounter{secnumdepth}{5}

\begin{document} \title{My most important work\vspace{-8pt}} \author{me} \date{\today} \maketitle
\tableofcontents \blinddocument \end{document}

Incidentally, I believe the background package may be deprecated in favour of the new hooks (but this would be another topic!).

cfr
  • 198,882