最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xelatex - How to fit all the text including headers and footers into a frame that will be formed by two centimeters of indentati

programmeradmin3浏览0评论

I need to fit all the text on the page into a frame. The margins on each edge are two centimeters. The headers and footers should be in a frame. That is, the header should start on the second centimeter from the beginning of the page. The footer should end before the second centimeter from the end of the page.

Here's what I tried

\documentclass[12pt, a4paper, titlepage]{extreport}

\usepackage{fontspec}
\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

\usepackage{polyglossia}
\setdefaultlanguage{latin}
\setotherlanguage{english}

\usepackage[
  a4paper,
  margin=2cm,
  includeheadfoot,
  noheadfoot,
  nomarginpar,
  showframe
]{geometry}

\usepackage{blindtext}

\begin{document}
\Blinddocument
\end{document}

But the footer is still outside the frame.

I need to fit all the text on the page into a frame. The margins on each edge are two centimeters. The headers and footers should be in a frame. That is, the header should start on the second centimeter from the beginning of the page. The footer should end before the second centimeter from the end of the page.

Here's what I tried

\documentclass[12pt, a4paper, titlepage]{extreport}

\usepackage{fontspec}
\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

\usepackage{polyglossia}
\setdefaultlanguage{latin}
\setotherlanguage{english}

\usepackage[
  a4paper,
  margin=2cm,
  includeheadfoot,
  noheadfoot,
  nomarginpar,
  showframe
]{geometry}

\usepackage{blindtext}

\begin{document}
\Blinddocument
\end{document}

But the footer is still outside the frame.

Share Improve this question edited Feb 15 at 13:20 samcarter_is_at_topanswers.xyz 38.9k5 gold badges57 silver badges76 bronze badges asked Feb 14 at 0:25 TimothéeTimothée 112 bronze badges 3
  • Cann you add a sketch how the result should look like? – samcarter_is_at_topanswers.xyz Commented Feb 14 at 9:22
  • Added a scetch for reference. – Timothée Commented Feb 15 at 13:16
  • Thanks. Also about xelatex: texdev/2024/11/05/engine-news-from-the-latex-project – samcarter_is_at_topanswers.xyz Commented Feb 15 at 13:24
Add a comment  | 

1 Answer 1

Reset to default 0

If you draw the frame separately, you could increase the bottom margin to whatever is needed to place the page number inside of the frame:

\documentclass[12pt, a4paper, titlepage]{extreport}

\usepackage[
  a4paper,
  margin=2cm,
  bottom=2.4cm,
  includeheadfoot,
  noheadfoot,
  nomarginpar,
]{geometry}

\usepackage{duckuments}

\usepackage{tikz}
\AddToHook{shipout/background}{
  \begin{tikzpicture}[remember picture,overlay]
    \draw[red] ([shift={(2cm,2cm)}]current page.south west) rectangle ([shift={(-2cm,-2cm)}]current page.north east);
  \end{tikzpicture}
}

\begin{document}
\duckument
\end{document}

发布评论

评论列表(0)

  1. 暂无评论