'여백에 있는 회전된 수직 상자의 장 제목'에 사용된 `\ChapFrame` 임시 제거

'여백에 있는 회전된 수직 상자의 장 제목'에 사용된 `\ChapFrame` 임시 제거

일시적으로 일부 챕터에 새로운 색상 상자를 할당하지 않고 싶습니다. 예를 들어 명령을 사용하거나 재설정하는 것이 가능합니까 \ChapFrame?

답변1

나는 당신이 \ChapFrame주어진 명령을 언급하고 있다고 가정합니다.this answer에게여백에 있는 회전된 수직 상자의 장 제목. 이 경우 대답은 '예'입니다. 조건에 따라 프레임을 활성화/비활성화할 수 있습니다. 약간의 예:

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

여기에 이미지 설명을 입력하세요

프레임을 활성화/비활성화하는 부울 스위치를 정의했습니다. 처음에는 부울이 true이므로 프레임이 그려집니다. 프레임을 비활성화하려는 위치에서 \Framefalse(앞에 \clearpage)를 사용하세요. 프레임을 활성화하려면 를 사용하면 됩니다 \Frametrue.

background또한 연결된 답변에 사용된 패키지 의 이전 구문에서 최신 구문으로 변경했습니다 . 물론 이전 구문을 사용한 코드를 계속 사용할 수 있습니다.

관련 정보