我想将文本框放在每个奇数页的右侧,以及每个偶数页的左侧。我不知道该怎么做。这是我的代码。
\documentclass[a4paper,twoside,12pt]{book}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
\chapter{ONE}
\noindent\fbox{%
\parbox{\textwidth}{%
\rotatebox{270}{\textcolor{blue}{\textbf{Please don't copy and sell this book.}}}
}%
}
\section{ABC}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
\newpage
\section{DEF}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
\end{document}
我想要如下结果
怎么做?
答案1
tikz 和 background 包的联合作用导致了这样的结果:
\documentclass[a4paper,twoside,12pt]{book}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{background}
\usepackage{tikzpagenodes}
\usepackage{ifthen}
\backgroundsetup%
{ angle=0,
opacity=1,
scale=1,
contents=%
{
\ifthenelse{\isodd{\thepage}}{%
\begin{tikzpicture}[remember picture,overlay]
\node[draw=black,text=blue,rotate=-90, above=1cm, text width=\textheight, align=center,font=\bfseries, inner sep=0.3cm] at (current page text area.east) {Please don't copy and sell this book.};
\end{tikzpicture}
}{
\begin{tikzpicture}[remember picture,overlay]
\node[draw=black,text=blue,rotate=90, above=1cm, text width=\textheight,align=center,font=\bfseries, inner sep=0.3cm] at (current page text area.west) {Please don't copy and sell this book.};
\end{tikzpicture}
}
}
}
\begin{document}
\chapter{ONE}
\section{ABC}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
\newpage
\section{DEF}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
\end{document}
答案2
使用 和 非常简单eso-pic
。ifoddpage
请注意,我没有保留框架,但添加它们很容易。
\documentclass[a4paper,twoside,12pt]{book}
\usepackage[margin=3cm]{geometry}
\usepackage{graphicx, rotating}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{eso-pic, ifoddpage}
\usepackage{lipsum}
\AddToShipoutPictureBG{\checkoddpage\ifoddpage
\AtPageLowerLeft{\hspace*{\dimexpr\paperwidth-2.4cm}
\rotatebox{90}{\makebox[\paperheight]{\textcolor{SteelBlue!70}{\small\textbf{Please don't copy and sell this book.}}}}}%
\else\AtPageUpperLeft{\hspace*{1.8cm} \rotatebox{-90}{\makebox[\paperheight]{\textcolor{SteelBlue!70}{\small\textbf{Please don't copy and sell this book.}}}}}\fi%
}%
\begin{document}
\chapter{ONE}
\section{ABC}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
\newpage
\section{DEF}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
\lipsum
\end{document}