How to print section titles like tab-list?












21















Can I create a user manual with sections at the right like multi-tab?



Like this:



demo



--
I think maybe I can template the page by tikz. (That will be very flexible if possible) so I added the tikz tag.










share|improve this question





























    21















    Can I create a user manual with sections at the right like multi-tab?



    Like this:



    demo



    --
    I think maybe I can template the page by tikz. (That will be very flexible if possible) so I added the tikz tag.










    share|improve this question



























      21












      21








      21


      10






      Can I create a user manual with sections at the right like multi-tab?



      Like this:



      demo



      --
      I think maybe I can template the page by tikz. (That will be very flexible if possible) so I added the tikz tag.










      share|improve this question
















      Can I create a user manual with sections at the right like multi-tab?



      Like this:



      demo



      --
      I think maybe I can template the page by tikz. (That will be very flexible if possible) so I added the tikz tag.







      tikz-pgf book-design






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 29 at 18:14









      Glorfindel

      207129




      207129










      asked Oct 7 '12 at 1:44









      Xiè JìléiXiè Jìléi

      640418




      640418






















          2 Answers
          2






          active

          oldest

          votes


















          23














          Here's a possible option using the background package to place the border, the tabs and the page number:



          documentclass{article}
          usepackage[a5paper,vmargin=2cm]{geometry}
          usepackage{background}
          usepackage{etoolbox}
          usepackage{totcount}
          usepackage{lipsum}

          % to have access to the total number of sections
          regtotcounter{section}

          % every section starts on a new page
          pretocmd{section}{clearpage}{}{}

          % auxiliary lengths for the height of the frame and the width of each tab
          newlengthmylen
          newlengthmylena

          % style for the section tabs
          tikzset{tab/.style={
          text width=mylena,anchor=south,
          draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
          align=center,text height=20pt,
          text depth=25pt,inner sep=0pt,fill=gray!20,
          yshift=-18pt,font=sffamilyLARGE}}
          % style for the current section tab
          tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

          % the page number is showed in the background material
          pagestyle{empty}

          AtBeginDocument{
          % calculation of the width for each tab
          setlengthmylen{dimexprtextheight+2cmrelax}
          ifnumtotvalue{section}>0
          setlengthmylena{dimexprmylen/totvalue{section}relax}
          fi

          % the main part; as background material we place the border,
          % the section (current and other) tabs and the page number
          backgroundsetup{
          scale=1,
          color=black,
          angle=0,
          opacity=1,
          contents= {
          begin{tikzpicture}[remember picture, overlay]
          node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
          at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
          foreach valsection in {0,...,numexprtotvalue{section}-1relax}
          {
          node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
          at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
          }
          node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
          text width=thedimexprtextwidth+1.5cmrelax,fill=white]
          at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
          node[font=LARGEsffamily,fill=white]
          at (border.south) {makebox[3em][c]{thepage}};
          end{tikzpicture}}
          }
          }

          begin{document}

          section{Test Section One}
          lipsum[1-3]
          section{Test Section Two}
          lipsum[1-3]
          section{Test Section Three}
          lipsum[1-3]
          section{Test Section Four}
          lipsum[2]

          end{document}


          enter image description here



          The document needs to be processed three times.



          If the most recent version for the background package is not available, here's the code using the syntax for version 1.0:



          documentclass{article}
          usepackage[a5paper,vmargin=2cm]{geometry}
          usepackage{background}
          usepackage{etoolbox}
          usepackage{totcount}
          usepackage{lipsum}

          % to have access to the total number of sections
          regtotcounter{section}

          % every section starts on a new page
          pretocmd{section}{clearpage}{}{}

          % auxiliary lengths for the height of the frame and the width of each tab
          newlengthmylen
          newlengthmylena

          % style for the section tabs
          tikzset{tab/.style={
          text width=mylena,anchor=south,
          draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
          align=center,text height=20pt,
          text depth=25pt,inner sep=0pt,fill=gray!20,
          yshift=-18pt,font=sffamilyLARGE}}
          % style for the current section tab
          tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

          % the page number is showed in the background material
          pagestyle{empty}

          AtBeginDocument{
          % calculation of the width for each tab
          setlengthmylen{dimexprtextheight+2cmrelax}
          ifnumtotvalue{section}>0
          setlengthmylena{dimexprmylen/totvalue{section}relax}
          fi

          % the main part; as background material we place the border,
          % the section (current and other) tabs and the page number
          SetBgScale{1}
          SetBgColor{black}
          SetBgAngle{0}
          SetBgOpacity{1}
          SetBgContents{
          begin{tikzpicture}[remember picture, overlay]
          node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
          at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
          foreach valsection in {0,...,numexprtotvalue{section}-1relax}
          {
          node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
          at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
          }
          node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
          text width=thedimexprtextwidth+1.5cmrelax,fill=white]
          at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
          node[font=LARGEsffamily,fill=white]
          at (border.south) {makebox[3em][c]{thepage}};
          end{tikzpicture}}
          }

          begin{document}

          section{Test Section One}
          lipsum[1-3]
          section{Test Section Two}
          lipsum[1-3]
          section{Test Section Three}
          lipsum[1-3]
          section{Test Section Four}
          lipsum[2]

          end{document}





          share|improve this answer


























          • I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

            – Xiè Jìléi
            Oct 7 '12 at 7:40













          • @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

            – Gonzalo Medina
            Oct 7 '12 at 15:17











          • It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

            – Xiè Jìléi
            Oct 7 '12 at 17:04











          • To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

            – Xiè Jìléi
            Oct 7 '12 at 17:10











          • @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

            – Gonzalo Medina
            Oct 7 '12 at 22:18





















          2














          Here is another suggestion based on the answer of @Gonzalo Medina but using the scrlayer package to define a layer pagestyle:



          documentclass{article}
          usepackage[a5paper,vmargin=2cm]{geometry}
          usepackage{tikz}% loads also xcolor and graphicx
          usepackage{totcount}
          usepackage{lipsum}% for dummy text
          usepackage{etoolbox}

          % to have access to the total number of sections
          regtotcounter{section}

          % every section starts on a new page
          pretocmd{section}{clearpage}{}{}

          % auxiliary length for the width of each tab
          newlengthmylena

          tikzset{
          tab/.style={% style for the section tabs
          text width=mylena,
          draw=gray,
          thick,
          rectangle,
          rounded corners=12pt,
          align=center,
          text width=53pt,
          inner sep=0pt,
          fill=gray!20,
          font=sffamilyLARGE,
          overlay
          },
          selectedtab/.style={% style for the current section tab
          tab,
          color=gray!90,
          text=white
          },
          pagenumber/.style={% style for the page number
          font=LARGEsffamily,
          fill=white,
          text width=3em,
          align=center
          }
          }

          usepackage{scrlayer}
          DeclarePageStyleByLayers{border}{border.odd,border.even}
          pagestyle{border}

          DeclareNewLayer[
          background,
          oddpage,
          textarea,
          addvoffset=-1cm,
          addhoffset=-.75cm,
          addheight=2cm,
          addwidth=1.5cm,
          contents={%
          ifnumtotvalue{section}>0
          setlengthmylena{dimexprlayerheight/totvalue{section}relax}%
          fi
          begin{tikzpicture}
          pgfdeclarelayer{background}
          pgfsetlayers{background,main}
          node[
          draw=gray,
          fill=white,
          inner sep=0pt,
          minimum width=layerwidth-pgflinewidth,
          minimum height=layerheight-pgflinewidth,
          rounded corners=10pt,
          line width=2pt
          ](border){};
          node[pagenumber]at (border.south){thepage};
          begin{pgfonlayer}{background}
          foreach valsection in {0,...,numexprtotvalue{section}-1relax}{%
          node[
          ifnumvalue{section}<numexprvalsection+1relax
          tab%
          else
          ifnumvalue{section}>numexprvalsection+1relax
          tab%
          else
          selectedtab%
          fi
          fi,
          minimum height=mylena-pgflinewidth
          ] at ([yshift=-(0.5+valsection)*mylena]border.north east)
          {%
          hspace*{25pt}rotatebox{-90}{Section thenumexprvalsection+1relax}%
          };
          }
          end{pgfonlayer}
          end{tikzpicture}%
          }
          ]{border.odd}

          DeclareNewLayer[
          clone=border.odd,
          evenpage,
          contents={%
          begin{tikzpicture}
          node[
          draw=gray,
          fill=white,
          inner sep=0pt,
          minimum width=layerwidth-pgflinewidth,
          minimum height=layerheight-pgflinewidth,
          rounded corners=10pt,
          line width=2pt
          ](border){};
          node[pagenumber]at (border.south){thepage};
          end{tikzpicture}%
          }
          ]{border.even}

          begin{document}
          section{Test Section One}
          lipsum[1-3]
          section{Test Section Two}
          lipsum[1-3]
          section{Test Section Three}
          lipsum[1-3]
          section{Test Section Four}
          lipsum[1-5]
          end{document}


          Run twice to get



          enter image description here



          As in the example above it is possible to define different layers for even an odd pages. For a twosided article



          documentclass[twoside]{article}


          the example above results in



          enter image description here






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f75637%2fhow-to-print-section-titles-like-tab-list%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            23














            Here's a possible option using the background package to place the border, the tabs and the page number:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            backgroundsetup{
            scale=1,
            color=black,
            angle=0,
            opacity=1,
            contents= {
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}


            enter image description here



            The document needs to be processed three times.



            If the most recent version for the background package is not available, here's the code using the syntax for version 1.0:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            SetBgScale{1}
            SetBgColor{black}
            SetBgAngle{0}
            SetBgOpacity{1}
            SetBgContents{
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}





            share|improve this answer


























            • I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

              – Xiè Jìléi
              Oct 7 '12 at 7:40













            • @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

              – Gonzalo Medina
              Oct 7 '12 at 15:17











            • It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

              – Xiè Jìléi
              Oct 7 '12 at 17:04











            • To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

              – Xiè Jìléi
              Oct 7 '12 at 17:10











            • @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

              – Gonzalo Medina
              Oct 7 '12 at 22:18


















            23














            Here's a possible option using the background package to place the border, the tabs and the page number:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            backgroundsetup{
            scale=1,
            color=black,
            angle=0,
            opacity=1,
            contents= {
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}


            enter image description here



            The document needs to be processed three times.



            If the most recent version for the background package is not available, here's the code using the syntax for version 1.0:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            SetBgScale{1}
            SetBgColor{black}
            SetBgAngle{0}
            SetBgOpacity{1}
            SetBgContents{
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}





            share|improve this answer


























            • I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

              – Xiè Jìléi
              Oct 7 '12 at 7:40













            • @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

              – Gonzalo Medina
              Oct 7 '12 at 15:17











            • It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

              – Xiè Jìléi
              Oct 7 '12 at 17:04











            • To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

              – Xiè Jìléi
              Oct 7 '12 at 17:10











            • @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

              – Gonzalo Medina
              Oct 7 '12 at 22:18
















            23












            23








            23







            Here's a possible option using the background package to place the border, the tabs and the page number:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            backgroundsetup{
            scale=1,
            color=black,
            angle=0,
            opacity=1,
            contents= {
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}


            enter image description here



            The document needs to be processed three times.



            If the most recent version for the background package is not available, here's the code using the syntax for version 1.0:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            SetBgScale{1}
            SetBgColor{black}
            SetBgAngle{0}
            SetBgOpacity{1}
            SetBgContents{
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}





            share|improve this answer















            Here's a possible option using the background package to place the border, the tabs and the page number:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            backgroundsetup{
            scale=1,
            color=black,
            angle=0,
            opacity=1,
            contents= {
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}


            enter image description here



            The document needs to be processed three times.



            If the most recent version for the background package is not available, here's the code using the syntax for version 1.0:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{background}
            usepackage{etoolbox}
            usepackage{totcount}
            usepackage{lipsum}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary lengths for the height of the frame and the width of each tab
            newlengthmylen
            newlengthmylena

            % style for the section tabs
            tikzset{tab/.style={
            text width=mylena,anchor=south,
            draw=gray,thick,rectangle,rounded corners=12pt,rotate=270,
            align=center,text height=20pt,
            text depth=25pt,inner sep=0pt,fill=gray!20,
            yshift=-18pt,font=sffamilyLARGE}}
            % style for the current section tab
            tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}

            % the page number is showed in the background material
            pagestyle{empty}

            AtBeginDocument{
            % calculation of the width for each tab
            setlengthmylen{dimexprtextheight+2cmrelax}
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprmylen/totvalue{section}relax}
            fi

            % the main part; as background material we place the border,
            % the section (current and other) tabs and the page number
            SetBgScale{1}
            SetBgColor{black}
            SetBgAngle{0}
            SetBgOpacity{1}
            SetBgContents{
            begin{tikzpicture}[remember picture, overlay]
            node[inner sep=0pt,text width=thedimexprtextwidth+1.5cmrelax]
            at (current page.center) (border) {rule{0pt}{dimexprtextheight+2cmrelax}};
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}
            {
            node[ifnumthesection<numexprvalsection+1relax tabelse ifnumthesection>numexprvalsection+1relax tabelse selectedtabfifi,xshift=(0.5+valsection)*mylena]
            at (border.north east) (tab-valsection) {Section thenumexprvalsection+1relax};
            }
            node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt,
            text width=thedimexprtextwidth+1.5cmrelax,fill=white]
            at (current page.center) {rule{0pt}{dimexprtextheight+2cmrelax}};
            node[font=LARGEsffamily,fill=white]
            at (border.south) {makebox[3em][c]{thepage}};
            end{tikzpicture}}
            }

            begin{document}

            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[2]

            end{document}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 7 '12 at 22:50

























            answered Oct 7 '12 at 5:37









            Gonzalo MedinaGonzalo Medina

            398k4113041572




            398k4113041572













            • I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

              – Xiè Jìléi
              Oct 7 '12 at 7:40













            • @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

              – Gonzalo Medina
              Oct 7 '12 at 15:17











            • It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

              – Xiè Jìléi
              Oct 7 '12 at 17:04











            • To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

              – Xiè Jìléi
              Oct 7 '12 at 17:10











            • @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

              – Gonzalo Medina
              Oct 7 '12 at 22:18





















            • I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

              – Xiè Jìléi
              Oct 7 '12 at 7:40













            • @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

              – Gonzalo Medina
              Oct 7 '12 at 15:17











            • It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

              – Xiè Jìléi
              Oct 7 '12 at 17:04











            • To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

              – Xiè Jìléi
              Oct 7 '12 at 17:10











            • @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

              – Gonzalo Medina
              Oct 7 '12 at 22:18



















            I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

            – Xiè Jìléi
            Oct 7 '12 at 7:40







            I can't compile with latex (or xelatex): ... ABD: EveryShipout initializing macros ! Undefined control sequence. @begindocumenthook ...}relax } backgroundsetup { scale=1, color=black, an... l.47 begin{document} ? I'm using TexLive 2012.

            – Xiè Jìléi
            Oct 7 '12 at 7:40















            @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

            – Gonzalo Medina
            Oct 7 '12 at 15:17





            @XièJìléi the problem is that your system has not the most recent version of the background package; you can update the package, or use the code with the old syntax that I just added to my answer. Please let me know if this made the code compilable.

            – Gonzalo Medina
            Oct 7 '12 at 15:17













            It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

            – Xiè Jìléi
            Oct 7 '12 at 17:04





            It's my mistake: I was run with TeXLive 2010, I have just reinstalled TeXLive 2012, and both versions are okay now. Cheers!

            – Xiè Jìléi
            Oct 7 '12 at 17:04













            To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

            – Xiè Jìléi
            Oct 7 '12 at 17:10





            To highlight the current section, I added a selectedtab style, and coded: node[ifnumthesection<valsection tabelse ifnumthesection>valsection tabelse selectedtabfifi .... though it works, could it be shorter? I'm new to LaTeX programming.

            – Xiè Jìléi
            Oct 7 '12 at 17:10













            @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

            – Gonzalo Medina
            Oct 7 '12 at 22:18







            @XièJìléi I think it's OK (although I had to make a little correction to the valsection counter). I updated my answer with some modifications (including the highlighting for the current section, that I had forgotten about; thank you for reminding me about this).

            – Gonzalo Medina
            Oct 7 '12 at 22:18













            2














            Here is another suggestion based on the answer of @Gonzalo Medina but using the scrlayer package to define a layer pagestyle:



            documentclass{article}
            usepackage[a5paper,vmargin=2cm]{geometry}
            usepackage{tikz}% loads also xcolor and graphicx
            usepackage{totcount}
            usepackage{lipsum}% for dummy text
            usepackage{etoolbox}

            % to have access to the total number of sections
            regtotcounter{section}

            % every section starts on a new page
            pretocmd{section}{clearpage}{}{}

            % auxiliary length for the width of each tab
            newlengthmylena

            tikzset{
            tab/.style={% style for the section tabs
            text width=mylena,
            draw=gray,
            thick,
            rectangle,
            rounded corners=12pt,
            align=center,
            text width=53pt,
            inner sep=0pt,
            fill=gray!20,
            font=sffamilyLARGE,
            overlay
            },
            selectedtab/.style={% style for the current section tab
            tab,
            color=gray!90,
            text=white
            },
            pagenumber/.style={% style for the page number
            font=LARGEsffamily,
            fill=white,
            text width=3em,
            align=center
            }
            }

            usepackage{scrlayer}
            DeclarePageStyleByLayers{border}{border.odd,border.even}
            pagestyle{border}

            DeclareNewLayer[
            background,
            oddpage,
            textarea,
            addvoffset=-1cm,
            addhoffset=-.75cm,
            addheight=2cm,
            addwidth=1.5cm,
            contents={%
            ifnumtotvalue{section}>0
            setlengthmylena{dimexprlayerheight/totvalue{section}relax}%
            fi
            begin{tikzpicture}
            pgfdeclarelayer{background}
            pgfsetlayers{background,main}
            node[
            draw=gray,
            fill=white,
            inner sep=0pt,
            minimum width=layerwidth-pgflinewidth,
            minimum height=layerheight-pgflinewidth,
            rounded corners=10pt,
            line width=2pt
            ](border){};
            node[pagenumber]at (border.south){thepage};
            begin{pgfonlayer}{background}
            foreach valsection in {0,...,numexprtotvalue{section}-1relax}{%
            node[
            ifnumvalue{section}<numexprvalsection+1relax
            tab%
            else
            ifnumvalue{section}>numexprvalsection+1relax
            tab%
            else
            selectedtab%
            fi
            fi,
            minimum height=mylena-pgflinewidth
            ] at ([yshift=-(0.5+valsection)*mylena]border.north east)
            {%
            hspace*{25pt}rotatebox{-90}{Section thenumexprvalsection+1relax}%
            };
            }
            end{pgfonlayer}
            end{tikzpicture}%
            }
            ]{border.odd}

            DeclareNewLayer[
            clone=border.odd,
            evenpage,
            contents={%
            begin{tikzpicture}
            node[
            draw=gray,
            fill=white,
            inner sep=0pt,
            minimum width=layerwidth-pgflinewidth,
            minimum height=layerheight-pgflinewidth,
            rounded corners=10pt,
            line width=2pt
            ](border){};
            node[pagenumber]at (border.south){thepage};
            end{tikzpicture}%
            }
            ]{border.even}

            begin{document}
            section{Test Section One}
            lipsum[1-3]
            section{Test Section Two}
            lipsum[1-3]
            section{Test Section Three}
            lipsum[1-3]
            section{Test Section Four}
            lipsum[1-5]
            end{document}


            Run twice to get



            enter image description here



            As in the example above it is possible to define different layers for even an odd pages. For a twosided article



            documentclass[twoside]{article}


            the example above results in



            enter image description here






            share|improve this answer




























              2














              Here is another suggestion based on the answer of @Gonzalo Medina but using the scrlayer package to define a layer pagestyle:



              documentclass{article}
              usepackage[a5paper,vmargin=2cm]{geometry}
              usepackage{tikz}% loads also xcolor and graphicx
              usepackage{totcount}
              usepackage{lipsum}% for dummy text
              usepackage{etoolbox}

              % to have access to the total number of sections
              regtotcounter{section}

              % every section starts on a new page
              pretocmd{section}{clearpage}{}{}

              % auxiliary length for the width of each tab
              newlengthmylena

              tikzset{
              tab/.style={% style for the section tabs
              text width=mylena,
              draw=gray,
              thick,
              rectangle,
              rounded corners=12pt,
              align=center,
              text width=53pt,
              inner sep=0pt,
              fill=gray!20,
              font=sffamilyLARGE,
              overlay
              },
              selectedtab/.style={% style for the current section tab
              tab,
              color=gray!90,
              text=white
              },
              pagenumber/.style={% style for the page number
              font=LARGEsffamily,
              fill=white,
              text width=3em,
              align=center
              }
              }

              usepackage{scrlayer}
              DeclarePageStyleByLayers{border}{border.odd,border.even}
              pagestyle{border}

              DeclareNewLayer[
              background,
              oddpage,
              textarea,
              addvoffset=-1cm,
              addhoffset=-.75cm,
              addheight=2cm,
              addwidth=1.5cm,
              contents={%
              ifnumtotvalue{section}>0
              setlengthmylena{dimexprlayerheight/totvalue{section}relax}%
              fi
              begin{tikzpicture}
              pgfdeclarelayer{background}
              pgfsetlayers{background,main}
              node[
              draw=gray,
              fill=white,
              inner sep=0pt,
              minimum width=layerwidth-pgflinewidth,
              minimum height=layerheight-pgflinewidth,
              rounded corners=10pt,
              line width=2pt
              ](border){};
              node[pagenumber]at (border.south){thepage};
              begin{pgfonlayer}{background}
              foreach valsection in {0,...,numexprtotvalue{section}-1relax}{%
              node[
              ifnumvalue{section}<numexprvalsection+1relax
              tab%
              else
              ifnumvalue{section}>numexprvalsection+1relax
              tab%
              else
              selectedtab%
              fi
              fi,
              minimum height=mylena-pgflinewidth
              ] at ([yshift=-(0.5+valsection)*mylena]border.north east)
              {%
              hspace*{25pt}rotatebox{-90}{Section thenumexprvalsection+1relax}%
              };
              }
              end{pgfonlayer}
              end{tikzpicture}%
              }
              ]{border.odd}

              DeclareNewLayer[
              clone=border.odd,
              evenpage,
              contents={%
              begin{tikzpicture}
              node[
              draw=gray,
              fill=white,
              inner sep=0pt,
              minimum width=layerwidth-pgflinewidth,
              minimum height=layerheight-pgflinewidth,
              rounded corners=10pt,
              line width=2pt
              ](border){};
              node[pagenumber]at (border.south){thepage};
              end{tikzpicture}%
              }
              ]{border.even}

              begin{document}
              section{Test Section One}
              lipsum[1-3]
              section{Test Section Two}
              lipsum[1-3]
              section{Test Section Three}
              lipsum[1-3]
              section{Test Section Four}
              lipsum[1-5]
              end{document}


              Run twice to get



              enter image description here



              As in the example above it is possible to define different layers for even an odd pages. For a twosided article



              documentclass[twoside]{article}


              the example above results in



              enter image description here






              share|improve this answer


























                2












                2








                2







                Here is another suggestion based on the answer of @Gonzalo Medina but using the scrlayer package to define a layer pagestyle:



                documentclass{article}
                usepackage[a5paper,vmargin=2cm]{geometry}
                usepackage{tikz}% loads also xcolor and graphicx
                usepackage{totcount}
                usepackage{lipsum}% for dummy text
                usepackage{etoolbox}

                % to have access to the total number of sections
                regtotcounter{section}

                % every section starts on a new page
                pretocmd{section}{clearpage}{}{}

                % auxiliary length for the width of each tab
                newlengthmylena

                tikzset{
                tab/.style={% style for the section tabs
                text width=mylena,
                draw=gray,
                thick,
                rectangle,
                rounded corners=12pt,
                align=center,
                text width=53pt,
                inner sep=0pt,
                fill=gray!20,
                font=sffamilyLARGE,
                overlay
                },
                selectedtab/.style={% style for the current section tab
                tab,
                color=gray!90,
                text=white
                },
                pagenumber/.style={% style for the page number
                font=LARGEsffamily,
                fill=white,
                text width=3em,
                align=center
                }
                }

                usepackage{scrlayer}
                DeclarePageStyleByLayers{border}{border.odd,border.even}
                pagestyle{border}

                DeclareNewLayer[
                background,
                oddpage,
                textarea,
                addvoffset=-1cm,
                addhoffset=-.75cm,
                addheight=2cm,
                addwidth=1.5cm,
                contents={%
                ifnumtotvalue{section}>0
                setlengthmylena{dimexprlayerheight/totvalue{section}relax}%
                fi
                begin{tikzpicture}
                pgfdeclarelayer{background}
                pgfsetlayers{background,main}
                node[
                draw=gray,
                fill=white,
                inner sep=0pt,
                minimum width=layerwidth-pgflinewidth,
                minimum height=layerheight-pgflinewidth,
                rounded corners=10pt,
                line width=2pt
                ](border){};
                node[pagenumber]at (border.south){thepage};
                begin{pgfonlayer}{background}
                foreach valsection in {0,...,numexprtotvalue{section}-1relax}{%
                node[
                ifnumvalue{section}<numexprvalsection+1relax
                tab%
                else
                ifnumvalue{section}>numexprvalsection+1relax
                tab%
                else
                selectedtab%
                fi
                fi,
                minimum height=mylena-pgflinewidth
                ] at ([yshift=-(0.5+valsection)*mylena]border.north east)
                {%
                hspace*{25pt}rotatebox{-90}{Section thenumexprvalsection+1relax}%
                };
                }
                end{pgfonlayer}
                end{tikzpicture}%
                }
                ]{border.odd}

                DeclareNewLayer[
                clone=border.odd,
                evenpage,
                contents={%
                begin{tikzpicture}
                node[
                draw=gray,
                fill=white,
                inner sep=0pt,
                minimum width=layerwidth-pgflinewidth,
                minimum height=layerheight-pgflinewidth,
                rounded corners=10pt,
                line width=2pt
                ](border){};
                node[pagenumber]at (border.south){thepage};
                end{tikzpicture}%
                }
                ]{border.even}

                begin{document}
                section{Test Section One}
                lipsum[1-3]
                section{Test Section Two}
                lipsum[1-3]
                section{Test Section Three}
                lipsum[1-3]
                section{Test Section Four}
                lipsum[1-5]
                end{document}


                Run twice to get



                enter image description here



                As in the example above it is possible to define different layers for even an odd pages. For a twosided article



                documentclass[twoside]{article}


                the example above results in



                enter image description here






                share|improve this answer













                Here is another suggestion based on the answer of @Gonzalo Medina but using the scrlayer package to define a layer pagestyle:



                documentclass{article}
                usepackage[a5paper,vmargin=2cm]{geometry}
                usepackage{tikz}% loads also xcolor and graphicx
                usepackage{totcount}
                usepackage{lipsum}% for dummy text
                usepackage{etoolbox}

                % to have access to the total number of sections
                regtotcounter{section}

                % every section starts on a new page
                pretocmd{section}{clearpage}{}{}

                % auxiliary length for the width of each tab
                newlengthmylena

                tikzset{
                tab/.style={% style for the section tabs
                text width=mylena,
                draw=gray,
                thick,
                rectangle,
                rounded corners=12pt,
                align=center,
                text width=53pt,
                inner sep=0pt,
                fill=gray!20,
                font=sffamilyLARGE,
                overlay
                },
                selectedtab/.style={% style for the current section tab
                tab,
                color=gray!90,
                text=white
                },
                pagenumber/.style={% style for the page number
                font=LARGEsffamily,
                fill=white,
                text width=3em,
                align=center
                }
                }

                usepackage{scrlayer}
                DeclarePageStyleByLayers{border}{border.odd,border.even}
                pagestyle{border}

                DeclareNewLayer[
                background,
                oddpage,
                textarea,
                addvoffset=-1cm,
                addhoffset=-.75cm,
                addheight=2cm,
                addwidth=1.5cm,
                contents={%
                ifnumtotvalue{section}>0
                setlengthmylena{dimexprlayerheight/totvalue{section}relax}%
                fi
                begin{tikzpicture}
                pgfdeclarelayer{background}
                pgfsetlayers{background,main}
                node[
                draw=gray,
                fill=white,
                inner sep=0pt,
                minimum width=layerwidth-pgflinewidth,
                minimum height=layerheight-pgflinewidth,
                rounded corners=10pt,
                line width=2pt
                ](border){};
                node[pagenumber]at (border.south){thepage};
                begin{pgfonlayer}{background}
                foreach valsection in {0,...,numexprtotvalue{section}-1relax}{%
                node[
                ifnumvalue{section}<numexprvalsection+1relax
                tab%
                else
                ifnumvalue{section}>numexprvalsection+1relax
                tab%
                else
                selectedtab%
                fi
                fi,
                minimum height=mylena-pgflinewidth
                ] at ([yshift=-(0.5+valsection)*mylena]border.north east)
                {%
                hspace*{25pt}rotatebox{-90}{Section thenumexprvalsection+1relax}%
                };
                }
                end{pgfonlayer}
                end{tikzpicture}%
                }
                ]{border.odd}

                DeclareNewLayer[
                clone=border.odd,
                evenpage,
                contents={%
                begin{tikzpicture}
                node[
                draw=gray,
                fill=white,
                inner sep=0pt,
                minimum width=layerwidth-pgflinewidth,
                minimum height=layerheight-pgflinewidth,
                rounded corners=10pt,
                line width=2pt
                ](border){};
                node[pagenumber]at (border.south){thepage};
                end{tikzpicture}%
                }
                ]{border.even}

                begin{document}
                section{Test Section One}
                lipsum[1-3]
                section{Test Section Two}
                lipsum[1-3]
                section{Test Section Three}
                lipsum[1-3]
                section{Test Section Four}
                lipsum[1-5]
                end{document}


                Run twice to get



                enter image description here



                As in the example above it is possible to define different layers for even an odd pages. For a twosided article



                documentclass[twoside]{article}


                the example above results in



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 2 '16 at 15:05









                esddesdd

                59.1k34691




                59.1k34691






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f75637%2fhow-to-print-section-titles-like-tab-list%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents