챕터 표시 및 부록

챕터 표시 및 부록

documentclass를 사용하여 문서를 만들고 있습니다 book. 이 문서에서는 @TomBombadil의 답변을 사용하여 장 표시를 추가했습니다.장의 모든 페이지에 마커를 어떻게 넣을 수 있습니까?.

이상한 점은 장에서는 코드가 잘 작동하지만 부록을 추가할 때 적어도 나에게는 이상하고 불분명한 오류로 인해 문서를 생성할 수 없다는 것입니다.

패키지 PGF 수학 오류: 알 수 없는 함수 `A'('-A/20*29.69974').

내 코드는

\documentclass[11pt,a4paper]{book}
\usepackage{lipsum}


\let\MakeUppercase\relax
\usepackage{etex}%Makes able the use of many packages
\usepackage[toc,page]{appendix}
% \input{Preamble/tikz}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{xifthen}
\usepackage{totcount}
\regtotcounter{chapter}

\backgroundsetup%
{   contents={%
        \begin{tikzpicture}[overlay]
            \pgfmathtruncatemacro{\mytotalchapters}{\totvalue{chapter} > 0 ? \totvalue{chapter} : 20}
            \pgfmathsetmacro{\mypaperheight}{\paperheight/28.453}
            \pgfmathsetmacro{\mytop}{-(\thechapter-1)/\mytotalchapters*\mypaperheight}
            \pgfmathsetmacro{\mybottom}{-\thechapter/\mytotalchapters*\mypaperheight}
            \ifcase\thechapter
                \xdef\mycolor{white}
                \or \xdef\mycolor{red}
                \or \xdef\mycolor{orange}
                \or \xdef\mycolor{yellow}
                \or \xdef\mycolor{green}
                \or \xdef\mycolor{blue}
                \or \xdef\mycolor{violet}
%                 \or \xdef\mycolor{magenta}
%                 \or \xdef\mycolor{cyan}
                \else \xdef\mycolor{black}
            \fi
            \ifthenelse{\isodd{\value{page}}}
            {\fill[\mycolor] ($(current page.north east)+(0,\mytop)$) rectangle ($(current page.north east)+(-0.5,\mybottom)$);}
            {\fill[\mycolor] ($(current page.north west)+(0,\mytop)$) rectangle ($(current page.north west)+(0.5,\mybottom)$);}
        \end{tikzpicture}
    },
    scale=1,
    angle=0
}
\begin{document}
 \chapter{First chapter}
 \lipsum[1]
 \appendix
 \chapter{Appendix Chapter}
 \lipsum[1]
\end{document}

제거하면 \appendix모든 것이 잘 작동합니다. 왜 이런 일이 발생하고 어떻게 해결할 수 있는지 아시나요?

답변1

이 명령은 을 로 \appendix설정 하고 로 만듭니다 . 따라서 오류가 발생합니다. 카운터 를 사용하는 대신 다른 카운터를 사용하십시오. 여기에서는 a를 정의 하고 를 사용하여 각 장 후에 이를 강화했습니다 .\value{chapter}0\Alphchaptercounter\xpatchcmd

\documentclass[11pt,a4paper]{book}
\usepackage{lipsum}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\chapter}{\thispagestyle{plain}}
                    {\thispagestyle{plain}\stepcounter{counter}}
                    {}{}
\makeatother


\let\MakeUppercase\relax
\usepackage{etex}%Makes able the use of many packages
\usepackage[toc,page]{appendix}
% \input{Preamble/tikz}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{xifthen}
\usepackage{totcount}
\regtotcounter{counter}
\newcounter{counter}

\backgroundsetup%
{   contents={%
        \begin{tikzpicture}[overlay]
            \pgfmathtruncatemacro{\mytotalcounter}{\totvalue{counter} > 0 ? \totvalue{counter} : 20}
            \pgfmathsetmacro{\mypaperheight}{\paperheight/28.453}
            \pgfmathsetmacro{\mytop}{-(\thecounter-1)/\mytotalcounter*\mypaperheight}
            \pgfmathsetmacro{\mybottom}{-\thecounter/\mytotalcounter*\mypaperheight}
            \ifcase\thecounter
                \xdef\mycolor{white}
                \or \xdef\mycolor{red}
                \or \xdef\mycolor{orange}
                \or \xdef\mycolor{yellow}
                \or \xdef\mycolor{green}
                \or \xdef\mycolor{blue}
                \or \xdef\mycolor{violet}
%                 \or \xdef\mycolor{magenta}
%                 \or \xdef\mycolor{cyan}
                \else \xdef\mycolor{black}
            \fi
            \ifthenelse{\isodd{\value{page}}}
            {\fill[\mycolor] ($(current page.north east)+(0,\mytop)$) rectangle ($(current page.north east)+(-0.5,\mybottom)$);}
            {\fill[\mycolor] ($(current page.north west)+(0,\mytop)$) rectangle ($(current page.north west)+(0.5,\mybottom)$);}
        \end{tikzpicture}
    },
    scale=1,
    angle=0
}
\begin{document}
 \chapter{First chapter}

 \lipsum[1]
 \chapter{second chapter}
 \lipsum[1]
 \appendix
 \chapter{Appendix Chapter}
 \lipsum[1]
 %\showthe\value{counter}
\end{document}

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

관련 정보