0

what I want to have

Hello, as the simplified picture above shows (the colors are a bit different with my output below, it's okay), I want to produce an a5paper, it's probably not the smartest code but I wanted the header, the footer, and the first zone (zone A, light blue background, that includes zone B) to fill the whole width of the paper.

Zone A is a breakable space (probably tcolorbox is best) because it can exceed one page. It must extend through the entire width of the paper.

Zone B is nested inside zone A, and it is also breakable (must be a tcolorbox, or in the worst cases a tikzpicture because of some features I hid for simplicity). I read that a tcolorbox inside a tcolorbox is unbreakable by default, and that we should useenforce breakable. It doesn't work well unfortunately. It seems to break in the next page. So here is what I want by order of priority:

  1. to make the zone A and especially the zone B breakable

  2. the bottom margin to fit the lower tikzpicture (I even tried with geometry, it doesn't seem to work), not much higher, because now it seems very high if we insert text in the zone (C)

  3. to reduce the top margin for the pages other than the 1st (the 1st works just fine, I guess).

Here is my MWE followed by the output:

\documentclass[8pt,a5paper]{extarticle}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{slantsc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.misc,shapes.callouts}
\usepackage[skins,breakable]{tcolorbox}
\usepackage{lipsum}
\usepackage[pass]{geometry}
\geometry{top=0pt,bottom=0pt}
\setlength\parindent{0pt}
\hyphenpenalty=5000
\usepackage{pbsi}
% \DeclareMathAlphabet{\mathbit}{OT1}{cmr}{bx}{it}
% \renewcommand*\oldstylenums[1]{{\fontfamily{Montserrat-TOsF}\selectfont #1}}

\usepackage{helvet} 
\renewcommand{\familydefault}{\sfdefault}


\usepackage[shortlabels]{enumitem}

\newcommand{\fph}{% Definition of first page figure
    \begin{tikzpicture}[
      overlay, xshift=-\oddsidemargin-1in,
      yshift=-3cm+\topskip+1in+\topmargin+\headheight+\headsep]
        \fill[blue!80] (0,0) rectangle (14.8,3);
    \end{tikzpicture}
}

\renewcommand{\headrulewidth}{0.0pt}

\fancypagestyle{my1stpagestyle}{%
    \fancyhead[C]{}
    \fancyfoot[C]{
    \begin{tikzpicture}[
      overlay, xshift=-\oddsidemargin-7.32cm,
      yshift=1.8cm-\topskip-1in-\topmargin-\headheight-\headsep]
        \clip (0,-0.5) rectangle (\paperwidth,1);
    \fill[blue!80] (0,-0.5) rectangle (\paperwidth,1.2);
\foreach \v in {1,...,30} {\fill[white,rounded corners=1] (0.5*\v,1.25) -- ++(0,-0.7) -- ++ (0.05,-0.05) -- ++ (0.05,0.05) -- ++ (0,0.7)  -- cycle;}
\foreach \t in {1,...,8} {\fill[white,rounded corners=1] (2*\t,1.25) -- ++(0,-1) -- ++ (0.05,-0.05) -- ++ (0.05,0.05) -- ++ (0,1)  -- cycle;}
    \end{tikzpicture}
    }
}

\fancypagestyle{generalpagestyle}{%
    \fancyhead[C]{}%running header
    \fancyfoot[C]{\begin{tikzpicture}[
      overlay, xshift=-\oddsidemargin-7.32cm,
      yshift=1.8cm-\topskip-1in-\topmargin-\headheight-\headsep]
        \clip (0,-0.5) rectangle (\paperwidth,1);
    \fill[blue!80] (0,-0.5) rectangle (\paperwidth,1.2);
\foreach \v in {1,...,30} {\fill[white,rounded corners=1] (0.5*\v,1.25) -- ++(0,-0.7) -- ++ (0.05,-0.05) -- ++ (0.05,0.05) -- ++ (0,0.7)  -- cycle;}
\foreach \t in {1,...,8} {\fill[white,rounded corners=1] (2*\t,1.25) -- ++(0,-1) -- ++ (0.05,-0.05) -- ++ (0.05,0.05) -- ++ (0,1)  -- cycle;}
    \end{tikzpicture}
    }
    }
\pagestyle{generalpagestyle}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

    \thispagestyle{my1stpagestyle}
    \fph               % this takes no space

    \vspace*{-2.4cm}
    \hspace*{-1cm}\begin{tcolorbox}[enhanced,breakable,width=\paperwidth+0.08cm,colback=blue!20,frame hidden,sharp corners,enlarge left by=-2.045cm-\@totalleftmargin]
\lipsum[1]
\begin{tcolorbox}[colback=green!20, width=\textwidth,enhanced,breakable,
  enforce breakable, frame hidden]
\lipsum[1-7]
    
\end{tcolorbox}
\end{tcolorbox}
    \lipsum[1-5]

\end{document}

here are the important issues with the output

issues 1 and 2 issue 3

Thanks a million

EDIT: following samcarter_is_at_topanswers.xyz's comment, here is the output I expect of the second page (smaller margins):

output 2

8
  • The tcolorbox documentation has the following to say baout nesting breakable boxes: "But, a breakable box inside a breakable box will usually give a mess." Feb 18 at 12:19
  • Thank you for your comment. Is there a way to fix this? Zone A doesn't have to be a tcolorbox. Feb 18 at 13:12
  • at least how to reduce the top and bottom margins? I break the tcolorbox manually if it doesn't work well :/ Feb 18 at 14:15
  • Can you add a sketch how the second page should look like? I'm wondering if maybe adding the header/footer via fancyhdr and changing the page colour to blue would make more sense than using a box Feb 18 at 16:08
  • I edited the original post Feb 18 at 17:08

1 Answer 1

0

Well, I ended up breaking the tcolorbox manually. But the margin problem was solved by removing the option pass in the geometry package. Instead, I used

\documentclass{extarticle}
\usepackage[a5paper]{geometry}
\geometry{top=1cm,bottom=1cm,left=1cm,right=1cm}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .