Sphinx 生成的文档的自定义标题设计

Sphinx 生成的文档的自定义标题设计

我正在尝试在我们生成的 Sphinx 文档中设计自定义标题。黑色三角形必须接触该线。

结果应如下所示: 在此处输入图片描述

我在 LaTeX 中的最佳结果如下所示:

在此处输入图片描述

% Header and Footer
\makeatletter
  \fancypagestyle{normal}{
    \fancyhf{} % sets both header and footer to nothing
    \setlength{\headheight}{30pt}
    \fancyfoot[LE,RO]{{\MyHeaderFamily\thepage}}
    \fancyfoot[LO]{{\MyHeaderFamily\nouppercase{\rightmark}}}
    \fancyfoot[RE]{{\MyHeaderFamily\nouppercase{\leftmark}}}
    \fancyhead[RO,LE]{{
        \vspace{0pt}\scalebox{0.2}{
            \begin{tikzpicture}\fill[black, ultra thick] (1,1) -- (2,1) -- (1.5,0) -- cycle;
            \end{tikzpicture}
            }
        \vspace{0pt}\vbox to 0pt{\makebox[\headwidth]{\hrulefill}\vss}
        \\
        \vspace{0pt}\MyHeaderFamily SAFETY, \py@release}}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0.4pt}
  }
\makeatother

我尝试了 \vspace 的各种正值和负值,但没有效果。有谁能给我更好的办法吗?

提前致谢,

冈瑟

更新@Bernard:

% Header and Footer
\newcommand{\shiftleft}[2]{\makebox[0pt][r]{\makebox[#1][l]{#2}}}
\newcommand{\shiftright}[2]{\makebox[#1][r]{\makebox[0pt][l]{#2}}}
\makeatletter
  \fancypagestyle{normal}{
    \fancyhf{}
    \fancyfoot[LE,RO]{{\MyHeaderFamily\thepage}}
    \fancyfoot[LO]{{\MyHeaderFamily\nouppercase{\rightmark}}}
    \fancyfoot[RE]{{\MyHeaderFamily\nouppercase{\leftmark}}}
    \fancyhead[LE,RO]{{\MyHeaderFamily SAFETY}}
    \fancyhead[LO]{{\shiftright{8pt}{\raisebox{-4pt}{\LARGE $\blacktriangledown$}}}}
    \fancyhead[RE]{{\shiftleft{15pt}{\raisebox{-4pt}{\LARGE $\blacktriangledown$}}}}
    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0.4pt}
  }
\makeatother

渲染结果如下: 在此处输入图片描述

我比原来的设计更喜欢它!

谢谢你!

答案1

正如我的评论,该解决方案用于picture定位文本。

\documentclass[twoside]{article}

\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{amssymb}
\newcommand\MyHeaderFamily{\sffamily\Large}
\makeatletter
  \fancypagestyle{normal}{
    \fancyhf{} % sets both header and footer to nothing
    \setlength{\headheight}{30pt}
    \fancyfoot[LE,RO]{\MyHeaderFamily\thepage}
    \fancyfoot[LO]{\MyHeaderFamily\nouppercase{\rightmark}}
    \fancyfoot[RE]{\MyHeaderFamily\nouppercase{\leftmark}}
    \renewcommand{\headrulewidth}{2pt}
    \fancyhead[RO]{{\LARGE $\blacktriangledown$}%
        \setlength{\unitlength}{\baselineskip}%
        \begin{picture}(0,0)
          \put(0,-1.2){\makebox(0,0)[r]{\MyHeaderFamily SAFETY, Release 1.0}}
        \end{picture}}
    \fancyhead[LE]{%
        \setlength{\unitlength}{\baselineskip}%
        \begin{picture}(0,0)
          \put(0,-1.2){\makebox(0,0)[l]{\MyHeaderFamily SAFETY, Release 1.0}}
        \end{picture}%
      {\LARGE $\blacktriangledown$}}
    \renewcommand{\footrulewidth}{0.4pt}
  }
\makeatother
\pagestyle{normal}
\begin{document}
\section{Intro}

\lipsum

\end{document}

在此处输入图片描述

答案2

在 Pieter 和 Bernard 的帮助下,我能够重现原始设计。

\documentclass[twoside]{article}

\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{amssymb}
\newcommand\MyHeaderFamily{\sffamily\Large}
\newcommand{\shiftleft}[2]{\makebox[0pt][r]{\makebox[#1][l]{#2}}}
\newcommand{\shiftright}[2]{\makebox[#1][r]{\makebox[0pt][l]{#2}}}
\makeatletter
\fancypagestyle{normal}{
    \fancyhf{} % sets both header and footer to nothing
    \setlength{\headheight}{30pt}
    \fancyfoot[LE,RO]{\MyHeaderFamily\thepage}
    \fancyfoot[LO]{\MyHeaderFamily\nouppercase{\rightmark}}
    \fancyfoot[RE]{\MyHeaderFamily\nouppercase{\leftmark}}
    \renewcommand{\headrulewidth}{2pt}
    \fancyhead[RO]{\shiftleft{20pt}{\raisebox{-1ex}{\LARGE $\blacktriangledown$}}%
        \setlength{\unitlength}{\baselineskip}%
        \begin{picture}(0,0)
            \put(0,-1.2){\makebox(0,0)[r]{\MyHeaderFamily SAFETY, Release 1.0}}
    \end{picture}}
    \fancyhead[LE]{%
        \setlength{\unitlength}{\baselineskip}%
        \begin{picture}(0,0)
            \put(0,-1.2){\makebox(0,0)[l]{\MyHeaderFamily SAFETY, Release 1.0}}
        \end{picture}%
        \shiftright{8pt}{\raisebox{-1ex}{\LARGE $\blacktriangledown$}}}
    \renewcommand{\footrulewidth}{0.4pt}
}
\makeatother
\pagestyle{normal}
\begin{document}
    \section{Intro}
    
    \lipsum
    
\end{document}

在此处输入图片描述

谢谢大家!你们的帮助太宝贵了!

谨致问候,冈瑟

相关内容