Remoção temporária de `\ChapFrame` usado em 'Título do capítulo em caixa vertical girada na margem'

Remoção temporária de `\ChapFrame` usado em 'Título do capítulo em caixa vertical girada na margem'

Gostaria, temporariamente, de não atribuir novas caixas coloridas para alguns capítulos. Isso é possível, por exemplo, usando ou redefinindo o \ChapFramecomando?

Responder1

Presumo que você esteja se referindo ao \ChapFramecomando fornecido emthis answerparaTítulo do capítulo em caixa vertical girada na margem. Nesse caso, a resposta é sim, você pode ativar/desativar condicionalmente os frames. Um pequeno exemplo:

\documentclass{book}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{lipsum}

\pagestyle{plain}
\newif\ifFrame
\Frametrue

% background common settings
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
contents={}
}

% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}

% the list of colors to be used (add more if needed)
\newcommand\BoxColor{%
  \ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}

% the main command; the mandatory argument sets the color of the vertical box
\newcommand\ChapFrame{%
\AddEverypageHook{%
\ifFrame
\ifthenelse{\isodd{\value{page}}}
  {\backgroundsetup{contents={%
  \begin{tikzpicture}[overlay,remember picture]
  \node[
    fill=\BoxColor,
    inner sep=0pt,
    rectangle,
    text width=2cm,
    text height=4cm,
    align=center,
    anchor=north east
  ] 
  at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $) 
    {\rotatebox{90}{\hspace*{.3cm}%
      \parbox[c][1.5cm][t]{3.4cm}{%
        \raggedright\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}}}%
  }
  {\backgroundsetup{contents={%
  \begin{tikzpicture}[overlay,remember picture]
  \node[
    fill=\BoxColor,
    inner sep=0pt,
    rectangle,
    text width=2cm,
    text height=4cm,
    align=center,
    anchor=north west
  ] 
  at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $) 
    {\rotatebox{90}{\hspace*{.3cm}%
      \parbox[c][1.5cm][t]{3.4cm}{%
        \raggedright\textcolor{black}{\scshape\leftmark}}}};
  \end{tikzpicture}}}
  }
  \BgMaterial%
  \fi%
}%
  \stepcounter{chapshift}
}

% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}} 

\begin{document}

\chapter[intro]{Introduction}
\ChapFrame
\lipsum[1-7]

\chapter{Results}
\ChapFrame
\lipsum[1-7]

\chapter{Discussion}
\Framefalse
\lipsum[1-7]

\chapter{Conclusion}
\Frametrue
\ChapFrame
\lipsum[1-7]

\end{document}

insira a descrição da imagem aqui

Defini uma chave booleana para ativar/desativar os frames; inicialmente o booleano é verdadeiro, então os quadros são desenhados. Em qualquer local onde desejar desativar os frames, utilize \Framefalse(possível precedido de um \clearpage). Para ativar os frames, basta usar \Frametrue.

Também mudei da sintaxe antiga do backgroundpacote usado na resposta vinculada para a sintaxe mais recente. Claro, o código com a sintaxe antiga ainda pode ser usado.

informação relacionada