2

This question is extention for other my question Replacing \fancyhdr with \titlesec in complicated design documents.

When I use solution from answer to prevous question with LuaLaTeX and ltjsarticle class which I need, I found white space which could not be filled by ajusting these parameters:

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

enter image description here

What is the reason on these white space?

The MWE is...

\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}
  • The TeXLive includes ltjsarticle class. If you have not got it, install the luatexja package by your package manager or get from CTAN.
  • Please ignore invalid TOC settings - I can repair it myself.
  • Where would one get the IPAExMincho font? – Martin Schröder Oct 23 '14 at 08:45
  • Just activate japanese input in you computer. If it will not be required font, set another main font with \usepackage{luatexja-fontspec}. – Gurebu Bokofu Oct 23 '14 at 09:04
  • I got that working, but can not reproduce your problem. Please create a minimal working example (MWE) that illustrates your problem. – Martin Schröder Oct 23 '14 at 09:14
  • @Martin Schröder, I already added it in question field. It's just after picture. – Gurebu Bokofu Oct 23 '14 at 09:17
  • 1
    ltjsarticle.cls does strange things to the page layout. It is fighting geometry but it is doing more than that. It is also confusing TiKZ. There are multiple page sizes involved so that the page size TiKZ works with is not the same as the physical page. If you pass geometry the verbose option, you'll see mag is set to 1095. You can force it to be 1000 (which is 1:1) and this will shift the margins left and down. But then the white margin will appear right and top. I am not sure why the class is set up this way, but it does say it is alpha quality software! – cfr Oct 24 '14 at 15:08
  • I'll try waht you said, but please if you success in this experements, give an answer to make me give you reputation reward possible. – Gurebu Bokofu Oct 25 '14 at 00:24
  • I didn't really suggest anything to try, I'm afraid. If you try what I said, you will just have a different problem. – cfr Oct 26 '14 at 03:39
  • Have you looked at the documentation for these classes? I cannot say if it might be helpful as I do not understand Japanese but it might, for example, offer you a way to configure the page layout which would avoid the need for geometry. If so, that might well work better. – cfr Oct 26 '14 at 15:52

1 Answers1

1

My preferred solution would be to use a better behaved class. However, I'm assuming you are asking because that is not an option. If so, I recommend dropping the use of geometry and setting the page dimensions manually. I wouldn't normally recommend this, but the class does very odd things which I do not pretend to understand.

Note that if the class offers facilities for customising the margins, you should definitely use those facilities rather than doing things manually. Since I am assuming you can understand the documentation whereas I cannot, you will have to figure out whether or not this is the case for yourself.

This so-called solution is extremely kludgey and, I suspect, even more fragile. So:

Caveat emptor...

And, please,

Handle with Care!

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

manual layout

cfr
  • 198,882