使标题宽度与两列对齐

使标题宽度与两列对齐

我正在尝试为tufte-book班级设计一个标题。我已成功完成此操作:

在此处输入图片描述

但是我需要有一个与两列对齐的标题,而不仅仅是一列:

在此处输入图片描述

请帮我做到这一点。


% !TEX TS-program = xelatex
% !TEX encoding = UTF-8
\documentclass{biditufte-book}
\usepackage{ptext}
\usepackage{xcolor}

\usepackage{fancyhdr} % Required for header and footer configuration

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\normalsize\bfseries #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\normalsize\bfseries #1}{}} % Section text font settings
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{16.5pt}% fancyhdr tells you the length
\fancyhf{}
\fancyhead[LE]{%
  \small
  \makebox[-5pt][r]{ \pagenumbox{1cm}}%
  \pagehead{\quad\quad\quad\quad\nouppercase{\leftmark}\hfill}%
}
\fancyhead[LO]{%
  \small
    \makebox[-275pt][r]{ \pagenumbox{1cm}}%
  \pagehead{\hfill\nouppercase{\rightmark}\quad\quad\quad\quad}%
}

%\fancypagestyle{plain}{%
%  \renewcommand{\headrulewidth}{0pt}%
%  \fancyhf{}%
%  \fancyfoot[L]{ \pagenumbox{\textwidth}}%
%}


\newcommand{\pagenumbox}[1]{%
  \begingroup\fboxsep=0pt
  \colorbox{blue!20}{\pagestrut
    \makebox[#1][c]{\thepage}%
  }%
  \endgroup
}
\newcommand{\pagehead}[1]{%
  \begingroup\fboxsep=0pt
  \colorbox{blue}{\pagestrut
    \makebox[\textwidth][s]{#1}%
  }%
  \endgroup
}
\newcommand{\pagestrut}{%
  \vrule width 0pt 
    height 1.5\ht\strutbox 
    depth 1.5\dp\strutbox
}
% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}

\usepackage[localise=on]{xepersian}
\settextfont{Times New Roman}
\setdigitfont{Times New Roman}


\begin{document}
\chapter{مشاهده‌‌پذیری}
\ptext
\section{مقدمه}
\ptext[1-10]
\section{مقدمه}
\ptext[1]
\end{document}

答案1

如果需要整页标题,则应计算蓝色规则的整个宽度。如下图所示(其中文本区域使用 显示\usepackage{showframe}),规则的宽度等于文本区域的宽度 + 边距区域的宽度 + 中间的长度。因此:

\newlength{\bluerulelength}
\setlength{\bluerulelength}{\textwidth}
\addtolength{\bluerulelength}{\marginparsep}
\addtolength{\bluerulelength}{\marginparwidth}

(您还需要计算另一个长度,以便您的浅蓝色盒子处于良好的位置,见下文。)

在此处输入图片描述

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8
\documentclass{biditufte-book}
\usepackage{ptext}
\usepackage{xcolor}

\usepackage{showframe}

\usepackage{fancyhdr} % Required for header and footer configuration

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\normalsize\bfseries #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\normalsize\bfseries #1}{}} % Section text font settings
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{16.5pt}% fancyhdr tells you the length

\newlength{\bluerulelength}
\setlength{\bluerulelength}{\textwidth}
\addtolength{\bluerulelength}{\marginparsep}
\addtolength{\bluerulelength}{\marginparwidth}

\newlength{\pagenumberboxskip}
\setlength{\pagenumberboxskip}{-\bluerulelength}
\addtolength{\pagenumberboxskip}{1cm}
\addtolength{\pagenumberboxskip}{10pt}

\fancyhf{}
\fancyhead[LE]{%
    \small
    \makebox[-5pt][r]{ \pagenumbox{1cm}}%
    \pagehead{\quad\quad\quad\quad\nouppercase{\leftmark}\hfill}%
}
\fancyhead[LO]{%
    \small
    \makebox[\pagenumberboxskip][r]{ \pagenumbox{1cm}}%
    \pagehead{\hfill\nouppercase{\rightmark}\quad\quad\quad\quad}%
}

%\fancypagestyle{plain}{%
%  \renewcommand{\headrulewidth}{0pt}%
%  \fancyhf{}%
%  \fancyfoot[L]{ \pagenumbox{\textwidth}}%
%}


\newcommand{\pagenumbox}[1]{%
    \begingroup\fboxsep=0pt
    \colorbox{blue!20}{\pagestrut
        \makebox[#1][c]{\thepage}%
    }%
    \endgroup
}
\newcommand{\pagehead}[1]{%
    \begingroup\fboxsep=0pt
    \colorbox{blue}{\pagestrut
        \makebox[\bluerulelength][s]{#1}%
    }%
    \endgroup
}
\newcommand{\pagestrut}{%
    \vrule width 0pt 
    height 1.5\ht\strutbox 
    depth 1.5\dp\strutbox
}
% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
    \clearpage\ifodd\c@page\else
    \hbox{}
    \vspace*{\fill}
    \thispagestyle{empty}
    \newpage
    \fi}

\usepackage[localise=on]{xepersian}
\settextfont{Times New Roman}
\setdigitfont{Times New Roman}


\begin{document}
    \chapter{مشاهده‌‌پذیری}
    \ptext
    \section{مقدمه}
    \ptext[1-10]
    \section{مقدمه}
    \ptext[1]
\end{document}

上一个答案

您的问题来自于这样一个事实:对于奇数页,您定义了左边您的精美标题的一部分。您应该使用:

\fancyhead[RO]{%
    \small
    \makebox[0pt][r]{ \pagenumbox{1cm}}%
    \pagehead{\hfill\nouppercase{\rightmark}\quad\quad\quad\quad}%
}

(请注意,现在分别是\fancyhead[RO]\makebox[0pt]而不是\fancyhead[LO] \makebox[-275pt])。

我已使用 添加了文本区域边界的显示\usepackage{showframe}。您可以在最终文档中将其删除。

在此处输入图片描述

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8
\documentclass{biditufte-book}
\usepackage{ptext}
\usepackage{xcolor}

\usepackage{showframe}

\usepackage{fancyhdr} % Required for header and footer configuration

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\normalsize\bfseries #1}{}} % Chapter text font settings
\renewcommand{\sectionmark}[1]{\markright{\normalsize\bfseries #1}{}} % Section text font settings
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{16.5pt}% fancyhdr tells you the length
\fancyhf{}
\fancyhead[LE]{%
    \small
    \makebox[-5pt][r]{ \pagenumbox{1cm}}%
    \pagehead{\quad\quad\quad\quad\nouppercase{\leftmark}\hfill}%
}
\fancyhead[RO]{%
    \small
    \makebox[0pt][r]{ \pagenumbox{1cm}}%
    \pagehead{\hfill\nouppercase{\rightmark}\quad\quad\quad\quad}%
}

%\fancypagestyle{plain}{%
%  \renewcommand{\headrulewidth}{0pt}%
%  \fancyhf{}%
%  \fancyfoot[L]{ \pagenumbox{\textwidth}}%
%}


\newcommand{\pagenumbox}[1]{%
    \begingroup\fboxsep=0pt
    \colorbox{blue!20}{\pagestrut
        \makebox[#1][c]{\thepage}%
    }%
    \endgroup
}
\newcommand{\pagehead}[1]{%
    \begingroup\fboxsep=0pt
    \colorbox{blue}{\pagestrut
        \makebox[\textwidth][s]{#1}%
    }%
    \endgroup
}
\newcommand{\pagestrut}{%
    \vrule width 0pt 
    height 1.5\ht\strutbox 
    depth 1.5\dp\strutbox
}
% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
    \clearpage\ifodd\c@page\else
    \hbox{}
    \vspace*{\fill}
    \thispagestyle{empty}
    \newpage
    \fi}

\usepackage[localise=on]{xepersian}
\settextfont{Times New Roman}
\setdigitfont{Times New Roman}

\begin{document}
    \chapter{مشاهده‌‌پذیری}
    \ptext
    \section{مقدمه}
    \ptext[1-10]
    \section{مقدمه}
    \ptext[1]
\end{document}

相关内容