Skip to content
TheChatArchiveThe Chat Archive
grok-3-preview-02-24· xAIHugging Face LMArena Human Preference 140K

i want to add border for each page in my file in overleaf

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-r1-0528’s answer.
  1. User

    i want to add border for each page in my file in overleaf

  2. Assistant

    To add a border to each page of your document in Overleaf (LaTeX), you can use the fancybox package or the tikz package. Below are two methods to achieve this:


    Method 1: Using the fancybox Package

    The fancybox package provides a simple way to add borders to pages.

    1. Add the fancybox package to your document preamble.
    2. Use the \fancypage command to define the border style.

    Here’s an example:

    \documentclass[a4paper,12pt]{article}
    \usepackage{fancybox} % For page borders
    \usepackage{lipsum} % For dummy text (optional)
    
    % Define the border style
    \fancypage{\fbox}{}
    
    \begin{document}
    
    \section{First Section}
    \lipsum[1-10] % Dummy text to fill pages
    
    \end{document}
    

    Explanation:

    • \fancypage{\fbox}{} applies a simple rectangular border (\fbox) to each page.
    • You can customize the border style by replacing \fbox with other commands, such as \doublebox, \shadowbox, or \ovalbox (see the fancybox documentation for more options).

    Method 2: Using the tikz Package

    The tikz package provides more flexibility for creating custom borders, including colored or dashed borders.

    1. Add the tikz package to your document preamble.
    2. Use the background package to apply the border to every page.

    Here’s an example:

    \documentclass[a4paper,12pt]{article}
    \usepackage{tikz} % For drawing borders
    \usepackage{background} % For applying borders to all pages
    \usepackage{lipsum} % For dummy text (optional)
    
    % Define the border style using tikz
    \backgroundsetup{
        scale=1,
        angle=0,
        opacity=1,
        contents={
            \begin{tikzpicture}[remember picture, overlay]
                \draw[line width=1pt, color=black] % Border style (customize as needed)
                ([shift={(10mm,-10mm)}]current page.south west) % Bottom-left corner
                rectangle % Draw a rectangle
                ([shift={(-10mm,10mm)}]current page.north east); % Top-right corner
            \end{tikzpicture}
        }
    }
    
    \begin{document}
    
    \section{First Section}
    \lipsum[1-10] % Dummy text to fill pages
    
    \end{document}
    

    Explanation:

    • The background package is used to apply the border to every page.
    • The tikz code draws a rectangle around the page, with a margin of 10mm from the edges (you can adjust this by changing the shift values).
    • You can customize the border by modifying the line width, color, or adding options like dashed or dotted. For example:
      • For a red dashed border, use: \draw[line width=1pt, color=red, dashed].

    Method 3: Using the geometry and crop Packages

    If you want a simple border that also shows crop marks (useful for printing), you can use the crop package.

    Here’s an example:

    \documentclass[a4paper,12pt]{article}
    \usepackage[cam,a4,frame]{crop} % For page borders with crop marks
    \usepackage{lipsum} % For dummy text (optional)
    
    \begin{document}
    
    \section{First Section}
    \lipsum[1-10] % Dummy text to fill pages
    
    \end{document}
    

    Explanation:

    • The crop package with the frame option adds a border to each page.
    • The cam option adds crop marks, which are useful for printing purposes. If you don’t want crop marks, remove the cam option.

    Choosing the Right Method

    • Use Method 1 (fancybox) for simple, predefined border styles.
    • Use Method 2 (tikz) for highly customizable borders (e.g., colored, dashed, or complex designs).
    • Use Method 3 (crop) if you need a border for printing purposes with crop marks.

    Notes

    • Make sure to compile your document in Overleaf to see the borders.
    • If you want to apply borders only to specific pages, you can use the \thispagestyle command or wrap the content in a conditional block (let me know if you need help with this).

    Let me know if you need further assistance!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.