2

I need some text in the left and right side of the pdf vertically so I use the following code but an extra blank page appears and end please help.

\documentclass[twoside]{article}
\usepackage{lipsum}
\usepackage{atbegshi}
\usepackage{tikz}
\usepackage{adjustbox}
\usepackage{etoolbox}
\usepackage{xhfill}

\usepackage[paperheight=9.75in,paperwidth=7.25in]{geometry}
\begin{document}
\definecolor{headbox}{RGB}{215, 229, 232}
\def\LeftSideText{\fcolorbox{white}{headbox}{Left side text}}
\def\RightSideText{\fcolorbox{white}{headbox}{Right side text}}
%\makebox[2em]{\xdotfill{.4pt}}

\newcommand{\LeftSideBar}{
\begin{tikzpicture}[remember picture,overlay]
\draw[fill,color=orange]
([xshift=1cm,yshift=0cm]current page.south west) rectangle ([xshift=0cm,yshift=0cm]current page.north west);
\node [rotate=90] at ([xshift=1.2cm,yshift=7cm]current page.west) {\sffamily\bfseries\resizebox{!}{0.5cm}{\color{black}{\LeftSideText}}$\cdots$};%
\end{tikzpicture}
}% 

\newcommand{\RightSideBar}{
\begin{tikzpicture}[remember picture,overlay]
\draw[fill,color=white]
([xshift=-1cm,yshift=0cm]current page.south east) rectangle ([xshift=0cm,yshift=0cm]current page.north east);
\node [rotate=90] at ([xshift=-2cm,yshift=7cm]current page.east) {\sffamily\bfseries\resizebox{!}{0.5cm}{\color{black}{\RightSideText}}$\cdots$};%
\end{tikzpicture}
}% CadreDePage


\AtBeginShipout{
\ifnumodd{\thepage}{\LeftSideBar}{\RightSideBar}
}


\lipsum[1-20]
\end{document}

enter image description here

1

The problem is that the command you are using puts the stuff on the next page, which is why there one more page appeared. I openly admit that I was too lazy to look up the "correct" command in atbegshi. However, if I use eso-pic, which is based on atbegshi, and for which I know the "correct" command, the problem does not appear.

\documentclass[twoside]{article}
\usepackage{lipsum}
\usepackage{eso-pic}
\usepackage{tikz}
\usepackage{adjustbox}
%\usepackage{etoolbox}
%\usepackage{xhfill}
\usepackage[paperheight=9.75in,paperwidth=7.25in]{geometry}

\def\LeftSideText{\fcolorbox{white}{headbox}{Left side text}}%
\def\RightSideText{\fcolorbox{white}{headbox}{Right side text}}%
\newcommand{\LeftSideBar}{%
\begin{tikzpicture}[remember picture,overlay]
\draw[fill,color=orange]
([xshift=1cm,yshift=0cm]current page.south west) rectangle ([xshift=0cm,yshift=0cm]current page.north west);
\node [rotate=90] at ([xshift=1.2cm,yshift=7cm]current page.west) {\sffamily\bfseries\resizebox{!}{0.5cm}{\color{black}{\LeftSideText}}$\cdots$};%
\end{tikzpicture}}% 

\newcommand{\RightSideBar}{%
\begin{tikzpicture}[remember picture,overlay]
\draw[fill,color=white]
([xshift=-1cm,yshift=0cm]current page.south east) rectangle ([xshift=0cm,yshift=0cm]current page.north east);
\node [rotate=90] at ([xshift=-1cm,yshift=2cm]current page.east) 
{\sffamily\bfseries\resizebox{!}{0.5cm}{\color{black}{\RightSideText}}$\cdots$};%
\end{tikzpicture}}% CadreDePage
\definecolor{headbox}{RGB}{215, 229, 232}

\begin{document}
%\makebox[2em]{\xdotfill{.4pt}}



\AddToShipoutPictureBG{%
\ifnum\number\value{page}>1
\ifodd\number\value{page}%
\LeftSideBar%
\else%
\RightSideBar%
\fi%
\fi}


\lipsum[1-20]
\end{document}

enter image description here

  • In the First page did not need the vertical text. – Shalu Apr 4 at 17:10
  • @Shalu I removed it. – user121799 Apr 4 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.