这个问题是其他我的问题的延伸在复杂的设计文档中用 \titlesec 替换 \fancyhdr。
确实,我和日本人一起工作,根据这对我来说建议西拉特克斯和bxjsclasses是最佳的。当我尝试了上一个答案中的解决方案时,我得到了下图所示的输出。
包设置geometry
必须定义相同的参数,与以前一样,但框架位置无效,文章。
首先,仅供测试,您可以在 MWE 下使用 PDFLaTeX 进行编译。使用 XeLaTeX 进行测试时,请替换\documentclass[a4paper,twoside]{article}
为\documentclass[a4paper,twoside]{bxjsarticle}
。如果您还没有这个类,您可以获取它这里。
\documentclass[a4paper,twoside]{article}
\usepackage[svgnames,x11names]{xcolor}% you need this before tikz to avoid an option clash
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{geometry}
\geometry{% Please make twoside settings
bindingoffset=0mm,
left=13mm, %% or inner=23mm
right=18mm, %% or outer=18mm
top=11mm, bottom=11mm,
headsep=3mm,
footskip=3mm
}
\usepackage{titletoc}
\usepackage[pagestyles]{titlesec}
\usepackage{background}
\newcommand{\colourframe}[2][white]{%
\clearpage
\backgroundsetup{%
angle=0,
scale=1,
opacity=1,
contents={%
\begin{tikzpicture}[remember picture, overlay]
\path [fill=#2, even odd rule]
(current page.south west) rectangle (current page.north east)
($(current page text area.south west) - (2mm,2mm)$) rectangle ($(current page text area.north east) + (2mm,2mm)$)
;
\node [fill=#1, draw=black, anchor=north, text=black, inner xsep=5mm, inner ysep=1.5mm, yshift=-1mm] at ($(current page text area.south) - (0,2mm)$) {\thepage};
\end{tikzpicture}},
position=current page.south west,
nodeanchor=south west
}%
\pagestyle{colourfancy}%
\sethead[][][\thesection\quad\sectiontitle]{\thesection\quad\sectiontitle}{}{}%
\setfoot[][][]{}{}{}%
\colorlet{SectionFrameColor}{#2!50}%
\colorlet{SectionFillColor}{#2!20}%
\colorlet{SectionFontColor}{#2!80}%
\titleformat{\section}[hang]{%
\Large\sffamily\color{SectionFontColor}%
}{%
\begin{tikzpicture}
[
baseline={([yshift=-.8ex]current bounding box.center)},
]
\node [thick, draw=SectionFrameColor, fill=SectionFillColor, rectangle, rounded corners, text=white] {\thesection};
\end{tikzpicture}%
}{12pt}{}[{\titlerule[1pt]}]%
\titleformat{\paragraph}[hang]{\bfseries}{}{}{}[]}
\newpagestyle{colourfancy}[]{}
\newpagestyle{tocandintro}[]{\headrule\setheadrule{0.5mm}\footrule\setfootrule{0.5mm}}
\backgroundsetup{%
contents={},
}
\begin{document}
\pagestyle{tocandintro}
\sethead[Table of contents][][]{}{Table of contents}{\textsf{Table of contents}}
\setfoot[\thepage][][ABC Project]{ABC Project}{}{\thepage}
\tableofcontents
\clearpage% uncomment if you don't want to have Intro in the header of the final contents page
\sethead[Intro][][]{}{}{Intro}
Intro text
\colourframe[orange]{red}
\section{First Red section}
\subsection{Red A}
\subsubsection{Red AA}
\subsubsection{Red AB}
\newpage
% 2nd red page
\section{Second Red section}
\subsection{Red B}
\subsubsection{Red BA}
\subsubsection{Red BB}
\colourframe[cyan]{blue}
\section{Blue section}
\end{document}
请不要引起对奇怪的目录的注意:我可以自己修复它。
答案1
我没有 XeTeX,但使用 pLaTeX + dvipdfmx 时问题重现。(我推荐使用 (u)pLaTeX 进行日文排版,因为它很流行,速度快,质量好。)
删除\backgroundsetup
s 解决了问题。看来current page
in{tikzpicture}
和位置规范 in的组合\backgroundsetup
导致了意外行为。
\documentclass[a4paper,twoside, dvipdfmx]{jsarticle}
\usepackage[svgnames,x11names]{xcolor}% you need this before tikz to avoid an option clash
\usepackage{tikz,tikzpagenodes,pxpgfmark}
% pxpgfmark for using remember picture with platex + dvipdfmx
\usetikzlibrary{calc}
\usepackage{geometry}
\geometry{% Please make twoside settings
bindingoffset=0mm,
left=13mm, %% or inner=23mm
right=18mm, %% or outer=18mm
top=11mm, bottom=11mm,
headsep=3mm,
footskip=3mm
}
\usepackage{titletoc}
\usepackage[pagestyles]{titlesec}
\newcommand{\colourframe}[2][white]{%
\clearpage
\begin{tikzpicture}[remember picture, overlay]
\path [fill=#2, even odd rule]
(current page.south west) rectangle (current page.north east)
($(current page text area.south west) - (2mm,2mm)$) rectangle ($(current page text area.north east) + (2mm,2mm)$)
;
\node [fill=#1, draw=black, anchor=north, text=black, inner xsep=5mm, inner ysep=1.5mm, yshift=-1mm] at ($(current page text area.south) - (0,2mm)$) {\thepage};
\end{tikzpicture}%
\pagestyle{colourfancy}%
\sethead[][][\thesection\quad\sectiontitle]{\thesection\quad\sectiontitle}{}{}%
\setfoot[][][]{}{}{}%
\colorlet{SectionFrameColor}{#2!50}%
\colorlet{SectionFillColor}{#2!20}%
\colorlet{SectionFontColor}{#2!80}%
\titleformat{\section}[hang]{%
\Large\sffamily\color{SectionFontColor}%
}{%
\begin{tikzpicture}
[
baseline={([yshift=-.8ex]current bounding box.center)},
]
\node [thick, draw=SectionFrameColor, fill=SectionFillColor, rectangle, rounded corners, text=white] {\thesection};
\end{tikzpicture}%
}{12pt}{}[{\titlerule[1pt]}]%
\titleformat{\paragraph}[hang]{\bfseries}{}{}{}[]}
\newpagestyle{colourfancy}[]{}
\newpagestyle{tocandintro}[]{\headrule\setheadrule{0.5mm}\footrule\setfootrule{0.5mm}}
\begin{document}
\pagestyle{tocandintro}
\sethead[Table of contents][][]{}{Table of contents}{\textsf{Table of contents}}
\setfoot[\thepage][][ABC Project]{ABC Project}{}{\thepage}
\tableofcontents
\clearpage% uncomment if you don't want to have Intro in the header of the final contents page
\sethead[Intro][][]{}{}{Intro}
Intro text
\colourframe[orange]{red}
\section{First Red section}
\subsection{Red A}
\subsubsection{Red AA}
\subsubsection{Red AB}
\newpage
% 2nd red page
\section{Second Red section}
\subsection{Red B}
\subsubsection{Red BA}
\subsubsection{Red BB}
\colourframe[cyan]{blue}
\section{Blue section}
\end{document}