3

I am trying to do the design as shown on the picture below.

enter image description here

The background includes two layers: vertcal line pattern and gradient layer where is lower color is transperent and upper color is white as vertical lines.

The first problem: how to place text into the color boxes? This problem is related with titlesec package.

enter image description here

The second problem is layers management: how to place an object from patterns library below fading rectangle and above it - the part label? As you see, this problem also related with TikZ package.

The MVE is...

\documentclass[a4paper,twoside]{article}

\usepackage[svgnames,x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{fadings,patterns,backgrounds}

\usepackage{titletoc}
\usepackage[toctitles,pagestyles]{titlesec}

\usepackage{multicol}

\oddsidemargin=-10.4mm
\evensidemargin=-20.4mm
\topmargin=-22mm
\textwidth=190mm
\textheight=275mm
\headheight = 5mm
\headsep = 2mm
\footskip = 7mm

\titleformat{\part}[block]{\Large\sffamily}
  {\filright\Huge\sffamily\bfseries \hspace*{2mm}%
  \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
    \node[fill=DarkGoldenrod1,rectangle,rounded corners,text=white] {Part \thepart};
    \fill [Gold2,path fading=north] (-2,-1) rectangle (\columnwidth-22mm,1.5);
  \end{tikzpicture}}
  {1ex}
  {}
  []

\begin{document}
\part{The trends in art in XX}

\newpage\twocolumn
\part{The World Wars influence}

\newpage\onecolumn
\begin{multicols}{2}
\part{The IT influence}
\end{multicols}

\end{document} 
1
  • Considering layers: look for pgfonlayer in the TikZ/PGF reference manual.
    – yo'
    Oct 16, 2014 at 12:35

1 Answer 1

5

You can pass explicit option to titlesec and specify the title as #1. The following may serve as the launch pad for your further refining and improvements.

\documentclass[a4paper,twoside]{article}

\usepackage[svgnames,x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{fadings,patterns,backgrounds,fit}

\usepackage{titletoc}
\usepackage[toctitles,pagestyles,explicit]{titlesec}

\usepackage{multicol}

\oddsidemargin=-10.4mm
\evensidemargin=-20.4mm
\topmargin=-22mm
\textwidth=190mm
\textheight=275mm
\headheight = 5mm
\headsep = 2mm
\footskip = 7mm

\titleformat{\part}[block]{}{}{1ex}%
  {\begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
    %\fill [Gold2,path fading=north] (0,-1) rectangle (\columnwidth,1.5);
    \node[fill=DarkGoldenrod1,rectangle,rounded corners,text=white,anchor=west,font=\huge\bfseries\sffamily] (a) at (0,0) {Part
               \thepart};
    \node[fill=none,text width= 0.7\columnwidth,text=red,anchor=north west,align=left,font=\huge\bfseries\sffamily] (b) at (a.north east) {#1};
   \begin{scope}[on background layer]
   \node[fill=Gold2,path fading=north]  [fit = (a)(b)] (B)  {};
    \node[pattern=vertical lines,pattern color=blue!50,path fading=north]  [fit = (a)(b)] (A)  {};
    \end{scope}
  \end{tikzpicture}%
  }
  []

\begin{document}
\part{The trends in art in XX}

\newpage\twocolumn
\part{The World Wars influence}

\newpage\onecolumn
\begin{multicols}{2}
\part{The IT influence}
\end{multicols}

\end{document}

enter image description here

Without explicit option, you can do it like this (thanks to egreg)

First define

\newcommand{\mypart}[1]{%
  \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
    \node[fill=DarkGoldenrod1,rectangle,rounded corners,text=white,anchor=west,font=\huge\bfseries\sffamily] (a) at (0,0) {Part
               \thepart};
    \node[fill=none,text width= 0.7\columnwidth,text=red,anchor=north west,align=left,font=\huge\bfseries\sffamily] (b) at (a.north east) {#1};
   \begin{scope}[on background layer]
   \node[fill=Gold2,path fading=north]  [fit = (a)(b)] (B)  {};
    \node[pattern=vertical lines,pattern color=blue!50,path fading=north]  [fit = (a)(b)] (A)  {};
    \end{scope}
  \end{tikzpicture}%
  }

Then declare the \titleformat like

\titleformat{\part}[block]{}{}{1ex}%
  {\mypart}
  []

Full code again:

\documentclass[a4paper,twoside]{article}

\usepackage[svgnames,x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{fadings,patterns,backgrounds,fit}

\usepackage{titletoc}
\usepackage[toctitles,pagestyles]{titlesec}

\usepackage{multicol}

\oddsidemargin=-10.4mm
\evensidemargin=-20.4mm
\topmargin=-22mm
\textwidth=190mm
\textheight=275mm
\headheight = 5mm
\headsep = 2mm
\footskip = 7mm

\newcommand{\mypart}[1]{%
  \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
    \node[fill=DarkGoldenrod1,rectangle,rounded corners,text=white,anchor=west,font=\huge\bfseries\sffamily] (a) at (0,0) {Part
               \thepart};
    \node[fill=none,text width= 0.7\columnwidth,text=red,anchor=north west,align=left,font=\huge\bfseries\sffamily] (b) at (a.north east) {#1};
   \begin{scope}[on background layer]
   \node[fill=Gold2,path fading=north]  [fit = (a)(b)] (B)  {};
    \node[pattern=vertical lines,pattern color=blue!50,path fading=north]  [fit = (a)(b)] (A)  {};
    \end{scope}
  \end{tikzpicture}%
  }

\titleformat{\part}[block]{}{}{1ex}%
  {\mypart}
  []

\begin{document}
\part{The trends in art in XX}

\newpage\twocolumn
\part{The World Wars influence}

\newpage\onecolumn
\begin{multicols}{2}
\part{The IT influence}
\end{multicols}

\end{document}

If you want to change the height of the rectangle, play with ,minimum height=2cm,yshift=0.5cm in

\begin{scope}[on background layer]
   \node[fill=Gold2,path fading=north,minimum height=2cm,yshift=0.5cm]  [fit = (a)(b)] (B)  {};
    \node[pattern=vertical lines,pattern color=blue!50,path fading=north,minimum height=2cm,yshift=0.5cm]  [fit = (a)(b)] (A)  {};
    \end{scope}

enter image description here

6
  • I'd surely prefer doing \newcommand{\bokofuformat}[1]{<the TikZ code depending on #1>} and then \titleformat...{\bokofuformat} so not needing the explicit option. The last token in the final mandatory argument to \titleformat can always be a one parameter macro, it will receive the title as argument.
    – egreg
    Oct 16, 2014 at 13:32
  • @egreg That is a good option. I will add it too. Thanks.
    – user11232
    Oct 16, 2014 at 13:35
  • The code is also better laid out, in my opinion. To each command its task.
    – egreg
    Oct 16, 2014 at 13:37
  • @egreg I agree. :-)
    – user11232
    Oct 16, 2014 at 13:40
  • Excellent solution, thank you! Just one question more: is it difficult if I need to change the background retangles height? Oct 17, 2014 at 9:20

You must log in to answer this question.

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