파일

파일

LaTeX을 배우고 있습니다. 나는 fancyhdr책 문서 클래스에서 를 사용하고 있습니다.

전체 페이지 너비를 차지하도록 수평선을 확장하고 싶습니다.

페이지 경계를 향해 확장된 헤더 규칙을 보여주는 스크린샷

시도했지만 \fancyheadoffset헤더 내용이 더 이상 페이지의 기본 내용과 정렬되지 않습니다.

전체 헤더는 페이지 너비를 가지며 헤더 내용은 포함됩니다.

\makebox나는 또한 a를 사용 하고 명령을 갱신하려고 시도했지만 \headrule제어할 수 없는 원치 않는 수직 공간을 생성합니다(이에 대한 답변을 기반으로 한 솔루션).질문).

어떻게 하면 hrule만 연장할 수 있나요?

예상 결과에 대한 시각적 설명

파일

책을 기반으로 한 문서 클래스

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{novel}[2024/02/01 Novel]


\LoadClass[12pt,a5paper,twoside,openright]{book}


% UTF-8 support.
\RequirePackage[utf8]{inputenc}


%%%%%%%%%%%
% Layout. %
%%%%%%%%%%%

% Basic layout.
\RequirePackage[
    papersize={152mm,214mm},
    layout=a5paper,
    layouthoffset=2mm,
    layoutvoffset=2mm,
    bindingoffset=8mm,
    left=17mm,
    right=17mm,
    top=17mm,
    bottom=17mm,
    %showframe
]{geometry}


%%%%%%%%%%%%%%%
% Formatting. %
%%%%%%%%%%%%%%%

% Helps build better header and footer; places the page number in the footer.
\RequirePackage{fancyhdr}

% Redefine fancy style.
\fancypagestyle{fancy}{

    \fancyheadoffset[loh,reh]{27mm}
    \fancyheadoffset[roh,leh]{19mm}

    \fancyhf{}
    \fancyhead[EL]{\smaller{\smaller{\textit{\MakeUppercase{\vspace{\baselineskip} \\ \thetitle}}}}}
    \fancyhead[OR]{\smaller{\smaller{\MakeUppercase{\chaptername\ \thechapter\ \\ \leftmark}}}}
    \renewcommand{\headrulewidth}{1pt}
    \fancyfoot[LE,RO]{\smaller{\thepage}}}

% Redefine plain style to match fancy style.
\fancypagestyle{plain}{
    \addtolength{\headwidth}{0cm}
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \fancyfoot[LE,RO]{\smaller{\thepage}}}

% Removes headers on empty pages.
\RequirePackage{emptypage}

% Used for convenient title management.
\RequirePackage{titling}

% Font size adjustment commands.
\RequirePackage{relsize}

% Reduces widows and orphans.
\RequirePackage[all]{nowidow}

% Change the chapter title in the header to only the chapter title.
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}


%%%%%%%%%%%%%%%
% Typography. %
%%%%%%%%%%%%%%%

% Fixes some hyphenation issues (lines longer than body width).
\sloppy

% Micro-typographical adjustments. TODO: reevaluate usefulness
\RequirePackage{microtype}

% Remove space between paragraphs.
\RequirePackage[skip=0pt,indent=15pt]{parskip}

기본 TeX 파일

\documentclass[]{novel}


% This is necessary for proper language-specific hyphenation.
\usepackage[french]{babel}

\usepackage[]{lipsum}


%%%%%%%%%%%%%
% Metadata. %
%%%%%%%%%%%%%

\author{NemuLumeN}
\title{Title of the book}
\date{2022}

\pagestyle{fancy}

\begin{document}

\maketitle

\tableofcontents

\chapter{First chapter title}


\lipsum[1-10]


\chapter{Second chapter}

Oh yeah
\end{document}

답변1

그래서 @Tom의 제안에 따라 다른 질문의 makebox 솔루션을 사용하여 다시 시도하고 "shift" 옵션을 적용했는데 작동했습니다(제 생각에는).

\makeatletter
    \def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
        \makebox[\linewidth]{\rule[\linewidth]{\dimexpr(\paperwidth + 8mm)}{\headrulewidth}}
        \vskip-315.69928pt}}%
\makeatother

설명

원본 을 \headrule.​ ​규칙이 실제 페이지 너비에 정확히 맞는지는 확실하지 않지만 적어도 눈에 보이는 간격은 없습니다. (나는 이 규칙이 종이 한도를 넘어서는 것이라고 생각합니다.)fancyhdr\rule\makebox

로그에 다음 출력이 표시되었기 때문에 패키지 \vskip원본 을 조정해야 했습니다 .fancyhdr

Package fancyhdr Warning: \headheight is too small (12.0pt):
(fancyhdr) Make it at least 301.59924pt, for example:
(fancyhdr) \setlength{\headheight}{301.59924pt}.
(fancyhdr) You might also make \topmargin smaller to compensate:
(fancyhdr) \addtolength{\topmargin}{-289.59924pt}.

원본을 \vskip-315.69928pt로 변경하면 오류가 "수정"됩니다. 하지만 값이 설정되었는지 여부에 관계없이 시각적으로 변경되는 사항이 없기 때문에 정확히 무엇이 수정되었는지는 알 수 없습니다.

결과

짝수 페이지 캡처

홀수 페이지 캡처

관련 정보