ltjsarticle 类中的白色字段

ltjsarticle 类中的白色字段

这个问题是其他我的问题的延伸在复杂的设计文档中用 \titlesec 替换 \fancyhdr

当我使用 LuaLaTeX 回答上一个问题的解决方案时ltjs文章我需要的类,我发现无法通过调整这些参数来填充的空白:

...
($(current page text area.south west) - (2mm,2mm)$) rectangle ($(current page text area.north east) + (2mm,2mm)$)

在此处输入图片描述

这些空白处的原因是什么?

MWE 是...

\documentclass[a4paper,twoside,11pt]{ltjsarticle}

\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}
  \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}
  • TeXLive 包括ltjs文章类。如果你还没有,请luatexja通过你的包管理器安装包或从以下位置获取加拿大运输安全局
  • 请忽略无效的 TOC 设置 - 我可以自己修复它。

答案1

我更倾向于使用一个行为更好的类。但是,我假设你问这个问题是因为这不是一个选项。如果是这样,我建议放弃使用geometry并手动设置页面尺寸。我通常不会推荐这样做,但这个类做了一些我并不理解的奇怪事情。

请注意,如果课程提供了自定义边距的功能,您一定要使用这些功能,而不是手动操作。由于我假设您可以理解文档,而我不能,因此您必须自己弄清楚这是否是这种情况。

这种所谓的解决方案非常笨拙,而且我怀疑它甚至更加脆弱。因此:

买者自负...

还有,

小心轻放!

\documentclass[a4paper,twoside,11pt]{ltjsarticle}

\usepackage[svgnames,x11names]{xcolor}% you need this before tikz to avoid an option clash
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{calc}% based rather loosely on code from the introduction to the geometry manual
\setlength\textwidth{\paperwidth-31mm}% 13+18=31
\setlength\oddsidemargin{(\paperwidth-\textwidth)/2 - 1in - 2.5mm}% .5*(13-18)=-2.5
\setlength\evensidemargin{(\paperwidth-\textwidth)/2 - 1in + 2.5mm}% .5*(18-13)=2.5
\setlength\topmargin{11mm-1in}
\setlength\headsep{3mm}
\setlength\footskip{3mm}
\setlength\marginparwidth{0pt}
\setlength\marginparsep{0pt}
\setlength\textheight{\paperheight-\headheight-\headsep-\footskip-22mm}% 2*11=22

\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}
  \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}

手动布局

相关内容