精美的章节标题,第 2 部分

精美的章节标题,第 2 部分

此帖正在创建帖子这里。在输出文件的第 4 页上,其中节标题与章节缩略图对齐,发生以下情况:

在此处输入图片描述

是否可以使线条出现在章节缩略图后面?谢谢。

以下是原始帖子中的解决方案代码:

   \documentclass[11pt]{book}
    \usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,letterpaper]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage[demo]{graphicx}
    \usepackage{lipsum}
    \usepackage{xcolor}
    \definecolor{mybluei}{RGB}{52,177,201}
    \definecolor{myblueii}{RGB}{63,200,244}
    \definecolor{myblueiii}{RGB}{199,234,253}
    \definecolor{ultramarine}{RGB}{0,45,97}
    \usepackage{tikz}
    \usetikzlibrary{shadows.blur}
    \usetikzlibrary{shapes.symbols}
    \usepackage{etoolbox,fancyhdr}
    \usepackage[explicit,calcwidth]{titlesec}

    \makeatletter
    \newcommand{\thechapterimage}{}%
    \newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}%
    \def\@makechapterhead#1{%
    {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
    \if@mainmatter
    \fi\fi\par\vspace*{120\p@}\stepcounter{chapshift}}}
    \makeatother

    \newcommand\SectionFont{\usefont{T1}{qhv}{b}{n}\selectfont}
    \titleformat{\section}
      {\normalfont\SectionFont\color{myblueii}}
      {\tikz[baseline=(a.base), overlay]{
            \node[fill=mybluei, anchor=south west, outer sep=0, draw=none, inner sep=.5mm,
                text=white,font=\Large, text width=1.5cm, align=center, minimum height=8.5mm,
                label={[text=myblueii]right:#1}
            ] (a) {\thesection};
        \foreach \x in {.25,.5,.75}{%
        \draw[mybluei, ultra thick] (a) ($(a.south west)!\x!(a.north west)$) --++ (-4,0);
        }
        \draw[myblueii, ultra thick] ($(a.south east)!.25!(a.north east)$) --++ (\textwidth-1.6cm,0);
        }
      }
      {1em}
      {}

    \usetikzlibrary{calc}
    \pagestyle{plain}
    \newcounter{chapshift}
    \addtocounter{chapshift}{-1}
    \newcommand\BoxColor{%
      ultramarine}

    \def\subsectiontitle{}
    \renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize#1}{}}
    \renewcommand{\subsectionmark}[1]{\def\subsectiontitle{#1}}
    \pagestyle{fancy}
    \renewcommand{\headrule}{{\color{myblueii}%
    \hrule width\headwidth height\headrulewidth depth\headrulewidth}}
    \fancyhf{} \fancyhead[LE,RO]{
        \normalsize\colorbox{myblueii}{\color{white}\sffamily\bfseries\strut\quad\thepage\quad}
        }
    \fancyhead[LO]{\textcolor{mybluei} \rightmark%
    \begin{tikzpicture}[overlay,remember picture]
      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
        text height=4cm,align=center,anchor=north east]
      at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
      {\rotatebox{90}{\parbox{4cm}{%
       \centering\textcolor{white}{\bfseries\scshape\rightmark \\ \sffamily\subsectiontitle}}}};
      \end{tikzpicture}}
    \fancyhead[RE]{Testing Book%
      \begin{tikzpicture}[overlay,remember picture]
      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
        text height=4cm,align=center,anchor=north west]
      at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
      {\rotatebox{90}{\parbox{4cm}{%
        \centering\textcolor{white}{\bfseries\scshape\rightmark \\ \sffamily\subsectiontitle}}}};
      \end{tikzpicture}}

\makeatother

\setlength{\headheight}{14pt}

\begin{document}
\chapterimage{bishade}
\chapter{Testing}
\section{Test One}
\lipsum[1-2]
\section{Test Two}
\lipsum[1-2]
\chapter{Testing Three}
\section{Test Four}
\lipsum[1-2]
\section{Test Two}
\lipsum[1]
\newpage
\section{Test Two}
\lipsum[1]
\end{document} 

答案1

这是一个解决方案。我们需要做的就是改变\fancyhead[LO]-->\fancyfoot[LO]\fancyhead[RE]-->\fancyfoot[RE]

在此处输入图片描述

\documentclass[11pt]{book}
    \usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,letterpaper]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage[demo]{graphicx}
    \usepackage{lipsum}
    \usepackage{xcolor}
    \definecolor{mybluei}{RGB}{52,177,201}
    \definecolor{myblueii}{RGB}{63,200,244}
    \definecolor{myblueiii}{RGB}{199,234,253}
    \definecolor{ultramarine}{RGB}{0,45,97}
    \usepackage{tikz}
    \usetikzlibrary{shadows.blur}
    \usetikzlibrary{shapes.symbols}
    \usepackage{etoolbox,fancyhdr}
    \usepackage[explicit,calcwidth]{titlesec}

    \makeatletter
    \newcommand{\thechapterimage}{}%
    \newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}%
    \def\@makechapterhead#1{%
    {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
    \if@mainmatter
    \fi\fi\par\vspace*{120\p@}\stepcounter{chapshift}}}
    \makeatother

    \newcommand\SectionFont{\usefont{T1}{qhv}{b}{n}\selectfont}
    \titleformat{\section}
      {\normalfont\SectionFont\color{myblueii}}
      {\tikz[baseline=(a.base), overlay]{
            \node[fill=mybluei, anchor=south west, outer sep=0, draw=none, inner sep=.5mm,
                text=white,font=\Large, text width=1.5cm, align=center, minimum height=8.5mm,
                label={[text=myblueii]right:#1}
            ] (a) {\thesection};
        \foreach \x in {.25,.5,.75}{%
        \draw[mybluei, ultra thick] (a) ($(a.south west)!\x!(a.north west)$) --++ (-4,0);
        }
        \draw[myblueii, ultra thick] ($(a.south east)!.25!(a.north east)$) --++ (\textwidth-1.6cm,0);
        }
      }
      {1em}
      {}

    \usetikzlibrary{calc}
    \pagestyle{plain}
    \newcounter{chapshift}
    \addtocounter{chapshift}{-1}
    \newcommand\BoxColor{%
      ultramarine}

    \def\subsectiontitle{}
    \renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize#1}{}}
    \renewcommand{\subsectionmark}[1]{\def\subsectiontitle{#1}}
    \pagestyle{fancy}
    \renewcommand{\headrule}{{\color{myblueii}%
    \hrule width\headwidth height\headrulewidth depth\headrulewidth}}
    \fancyhf{} \fancyhead[LE,RO]{
        \normalsize\colorbox{myblueii}{\color{white}\sffamily\bfseries\strut\quad\thepage\quad}
        }
    \fancyfoot[LO]{\textcolor{mybluei} \rightmark%
    \begin{tikzpicture}[overlay,remember picture]
      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
        text height=4cm,align=center,anchor=north east]
      at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
      {\rotatebox{90}{\parbox{4cm}{%
       \centering\textcolor{white}{\bfseries\scshape\rightmark \\ \sffamily\subsectiontitle}}}};
      \end{tikzpicture}}
    \fancyfoot[RE]{Testing Book%
      \begin{tikzpicture}[overlay,remember picture]
      \node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
        text height=4cm,align=center,anchor=north west]
      at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
      {\rotatebox{90}{\parbox{4cm}{%
        \centering\textcolor{white}{\bfseries\scshape\rightmark \\ \sffamily\subsectiontitle}}}};
      \end{tikzpicture}}

\makeatother

\setlength{\headheight}{14pt}

\begin{document}
\chapterimage{bishade}
\chapter{Testing}
\section{Test One}
\lipsum[1-2]
\section{Test Two}
\lipsum[1-2]
\chapter{Testing Three}
\section{Test Four}
\lipsum[1-2]
\section{Test Two}
\lipsum[1]
\newpage
\section{Test Two}
\lipsum[1]
\end{document}

相关内容