Text Formattingfancybox outline not centered on page

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
G_Seibert
Posts: 1
Joined: Sat Jul 24, 2021 11:17 pm

fancybox outline not centered on page

Post by G_Seibert »

I am trying to draw an outline around the pages I submit for a report. I am using the following code.

Code: Select all

\documentclass{report}%
\usepackage[letterpaper, left=0.50in, right=0.50in, top=0.50in, 
bottom=1.00in]{geometry}
\usepackage{fancyhdr,fancybox} % Custom page headers and footers%
\usepackage{lastpage}

\pagestyle{fancy} % set page style to fancy%
\fancyfoot{} % clear the footers%
\fancyhead{} % clear the headers%
\renewcommand{\headrulewidth}{0pt} % Eliminate the head rule line%
\renewcommand{\footrulewidth}{2.0pt}
\pagenumbering{arabic}%

\fancyfoot[r]{\footnotesize \textbf{Page \thepage\ 
of~\pageref*{LastPage}}}%%

\fancypage{%
        \setlength\fboxsep{8pt}%
        \setlength\fboxrule{2pt}%
        \fbox}{}
\begin{document}
     Start of document \pageref{page2} and \pageref{page3}.
     \cleardoublepage
     this is page 2. \label{page2}
     \cleardoublepage
     this is page three \label{page3}
\end{document}
The problem is that the outline is not centered on the page. It is shifted to the right. Is there anyway I can correct this?

Thanks!

--
Jerry

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

fancybox outline not centered on page

Post by Bartman »

The dots shift the frame.

My suggestion for your approach:

Code: Select all

\documentclass{report}
\usepackage[
    letterpaper, 
    left=0.50in, right=0.50in, 
    top=0.50in, bottom=1.00in,
    showframe
]{geometry}
\usepackage{fancyhdr,fancybox} % Custom page headers and footers%
\usepackage{lastpage}

\pagestyle{fancy} % set page style to fancy%
\fancyhf{} % clear the headers and footers%
\renewcommand{\headrulewidth}{0pt} % Eliminate the head rule line%
\renewcommand{\footrulewidth}{2.0pt}

\fancyfoot[r]{
    \footnotesize \textbf{Page \thepage{} 
    of~\pageref{LastPage}}%
}

\fancypage{%
    \setlength\fboxrule{2pt}% dots removed
    \setlength\fboxsep{-\fboxrule}% see above
    \fbox% see above
}{}
\begin{document}
    Start of document \pageref{page2} and \pageref{page3}.
    \cleardoublepage
    this is page 2. \label{page2}
    \cleardoublepage
    this is page three \label{page3}
\end{document}
Another proposal with other packages:

Code: Select all

\documentclass{report}%
\usepackage[
    letterpaper, 
    left=0.50in, right=0.50in, 
    top=0.50in, bottom=1.00in,
    showframe
]{geometry}
\usepackage{fancyhdr} % Custom page headers and footers%
\usepackage{lastpage}
\usepackage{eso-pic}% offers \AddToShipoutPictureBG command
\usepackage{tikzpagenodes}% added

\pagestyle{fancy} % set page style to fancy%
\fancyhf{} % clear the headers and footers%
\renewcommand{\headrulewidth}{0pt} % Eliminate the head rule line%
\renewcommand{\footrulewidth}{2.0pt}

\fancyfoot[r]{
    \footnotesize \textbf{Page \thepage{} 
    of~\pageref{LastPage}}
}

\AddToShipoutPictureBG{
    \tikz[remember picture, overlay]{
        \draw [line width=2pt]
            (current page text area.north west) rectangle 
            (current page text area.south east)
        ;
    }
}
\begin{document}
    Start of document \pageref{page2} and \pageref{page3}.
    \cleardoublepage
    this is page 2. \label{page2}
    \cleardoublepage
    this is page three \label{page3}
\end{document}
Post Reply