我正在編寫一份文檔,我想在除目錄頁之外的所有頁邊距上放置一個垂直方向的句子。
我的程式碼是:
\documentclass[12pt,a4paper,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{eso-pic}
\makeatletter
\newlength\@tempdim@x
\newlength\@tempdim@y
% structure des commandes :
% #1 = deplacement selon x
% #2 = deplacement selon y
% #3 = texte à mettre
\newcommand\AtUpperLeftCorner[3]{%
\begingroup
\@tempdim@x=0cm
\@tempdim@y=\paperheight
\advance\@tempdim@x#1
\advance\@tempdim@y-#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtUpperRightCorner[3]{%
\begingroup
\@tempdim@x=\paperwidth
\@tempdim@y=\paperheight
\advance\@tempdim@x-#1
\advance\@tempdim@y-#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtLowerLeftCorner[3]{%
\begingroup
\@tempdim@x=0cm
\@tempdim@y=0cm
\advance\@tempdim@x#1
\advance\@tempdim@y#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtLowerRightCorner[3]{%
\begingroup
\@tempdim@x=\paperwidth
\@tempdim@y=0cm
\advance\@tempdim@x-#1
\advance\@tempdim@y#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\AddToShipoutPicture{%
\AtLowerRightCorner{2cm}{5cm}{\ifodd\c@page\ifnum\arabic{page}>1 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
\AtLowerLeftCorner{2cm}{5cm}{\ifodd\c@page\else\ifnum\arabic{page}>1 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
}
\makeatother
\pagenumbering{roman}
\begin{document}
{\pagestyle{plain}
\tableofcontents}
\chapter{Chapter one}
\pagenumbering{arabic}
\section{one}
\lipsum[2]
\section{two}
\lipsum[4]
\section{three}
\lipsum[11]
\chapter{Chapter two}
\section{four}
\lipsum[1]
\end{document}
答案1
您可以將 if 與頁面的值一起放置:
\AddToShipoutPicture{%
\AtLowerRightCorner{2cm}{5cm}{\ifodd\c@page\ifnum\value{page}>1 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
\AtLowerLeftCorner{2cm}{5cm}{\ifodd\c@page\else\ifnum\value{page}>1 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
}
如果您願意,可以定義計數器並將其設定為列印目錄後的頁碼,並添加此值以自動化該過程(可能會更複雜一些,因為目錄是在列印後列印的)第二次編譯。
編輯:(這些東西的解決方法mainmatter
)
\newcounter{realpage}
\AddToShipoutPicture{%
\AtLowerRightCorner{2cm}{5cm}{\ifodd\c@page\ifnum\value{realpage}>0 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
\AtLowerLeftCorner{2cm}{5cm}{\ifodd\c@page\else\ifnum\value{realpage}>0 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
}
\let\oldmainmatter\mainmatter
\def\mainmatter{\oldmainmatter\stepcounter{realpage}}
最後編輯:
\documentclass[12pt,a4paper,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{eso-pic}
\makeatletter
\newlength\@tempdim@x
\newlength\@tempdim@y
% structure des commandes :
% #1 = deplacement selon x
% #2 = deplacement selon y
% #3 = texte à mettre
\newcommand\AtUpperLeftCorner[3]{%
\begingroup
\@tempdim@x=0cm
\@tempdim@y=\paperheight
\advance\@tempdim@x#1
\advance\@tempdim@y-#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtUpperRightCorner[3]{%
\begingroup
\@tempdim@x=\paperwidth
\@tempdim@y=\paperheight
\advance\@tempdim@x-#1
\advance\@tempdim@y-#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtLowerLeftCorner[3]{%
\begingroup
\@tempdim@x=0cm
\@tempdim@y=0cm
\advance\@tempdim@x#1
\advance\@tempdim@y#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtLowerRightCorner[3]{%
\begingroup
\@tempdim@x=\paperwidth
\@tempdim@y=0cm
\advance\@tempdim@x-#1
\advance\@tempdim@y#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcounter{realpage}
\AddToShipoutPicture{%
\AtLowerRightCorner{2cm}{5cm}{\ifodd\c@page\ifnum\value{realpage}>0 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
\AtLowerLeftCorner{2cm}{5cm}{\ifodd\c@page\else\ifnum\value{realpage}>0 \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
}
\makeatother
\pagenumbering{roman}
\begin{document}
{\pagestyle{plain}
\tableofcontents}
\chapter{Chapter one}
\stepcounter{realpage}
\pagenumbering{arabic}
\section{one}
\lipsum[2]
\section{two}
\lipsum[4]
\section{three}
\lipsum[11]
\chapter{Chapter two}
\section{four}
\lipsum[1]
\end{document}
具有相同的序言...以便在目錄使用後在即將到來的可能為空的頁面中打印垂直文本,如下所示:
\begin{document}
{\pagestyle{plain}
\tableofcontents}
\clearpage
\stepcounter{realpage}
\chapter{Chapter one}
\pagenumbering{arabic}
\section{one}
\lipsum[2]
\section{two}
\lipsum[4]
\section{three}
\lipsum[11]
\chapter{Chapter two}
\section{four}
\lipsum[1]
\end{document}
答案2
您也可以手動設定標誌來開啟和關閉疊加。
\documentclass[12pt,a4paper,twoside,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lipsum}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{eso-pic}
\makeatletter
\newlength\@tempdim@x
\newlength\@tempdim@y
% structure des commandes :
% #1 = deplacement selon x
% #2 = deplacement selon y
% #3 = texte à mettre
\newcommand\AtUpperLeftCorner[3]{%
\begingroup
\@tempdim@x=0cm
\@tempdim@y=\paperheight
\advance\@tempdim@x#1
\advance\@tempdim@y-#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtUpperRightCorner[3]{%
\begingroup
\@tempdim@x=\paperwidth
\@tempdim@y=\paperheight
\advance\@tempdim@x-#1
\advance\@tempdim@y-#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtLowerLeftCorner[3]{%
\begingroup
\@tempdim@x=0cm
\@tempdim@y=0cm
\advance\@tempdim@x#1
\advance\@tempdim@y#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
\newcommand\AtLowerRightCorner[3]{%
\begingroup
\@tempdim@x=\paperwidth
\@tempdim@y=0cm
\advance\@tempdim@x-#1
\advance\@tempdim@y#2
\put(\LenToUnit{\@tempdim@x},\LenToUnit{\@tempdim@y}){#3}%
\endgroup
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% start edit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\iftoc
\AddToShipoutPicture{%
\AtLowerRightCorner{2cm}{5cm}{\ifodd\c@page\iftoc\else \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
\AtLowerLeftCorner{2cm}{5cm}{\ifodd\c@page\else\iftoc\else \rotatebox{90}{Good \raisebox{0.1ex}{--} My book}\fi\fi}
}
\makeatother
\pagenumbering{roman}
\begin{document}
{\pagestyle{plain}
\global\toctrue% or place outside braces
\tableofcontents}
\chapter{Chapter one}\tocfalse
\pagenumbering{arabic}
\section{one}
\lipsum[2]
\section{two}
\lipsum[4]
\section{three}
\lipsum[11]
\chapter{Chapter two}
\section{four}
\lipsum[1]
\end{document}