1

I have the following code that add some vertical border on pages but it's always on the same side (i.e. left side). So, for twoside documents, it won't look fine.

With the lesser changes, how to make it appear on the right on right pages and on the left on left pages?

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{eso-pic,picture}
\usepackage{xcolor}
\definecolor{gray4}{rgb}{0.4,0.4,0.4}
\definecolor{gray8}{rgb}{0.8,0.8,0.8}

\makeatletter
\AddToShipoutPicture{%
  \AtPageLowerLeft{%
    \hspace*{0.48cm}\rotatebox{90}{%
      \colorbox{gray8!44}{%
        \begin{minipage}{\paperheight}
          \sffamily
          \vspace*{0.4em}
          \centering
          \hspace*{\stretch{1}}
          \textcolor{gray4}{some vertical text here along the pages}
          \hspace*{\stretch{1}}
          \vspace*{0.4em}
        \end{minipage}%
      }%
    }%
  }%
}%
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\newpage{}
\section{Intro}
\newpage{}
\section{Methods}
\newpage{}

\end{document} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1
  • See background and/or tikzpagenodes?
    – cfr
    Jul 24, 2017 at 1:51

1 Answer 1

2

I found a solution but I had an issue (that I can't reproduce with my MWE, so it must be in conflict with some other package) with the footmisc package that I had to place before the new one in the preamble:

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{eso-pic,picture}
\usepackage{xcolor}
\definecolor{gray4}{rgb}{0.4,0.4,0.4}
\definecolor{gray8}{rgb}{0.8,0.8,0.8}
\usepackage[bottom]{footmisc}
\usepackage{scrextend} % New package inserted !


\makeatletter
\AddToShipoutPicture{%
 \ifthispageodd{% define by newly inserted package ! It's an if{true}{false} structure.
  \AtPageLowerLeft{%
   \put(\LenToUnit{\dimexpr\paperwidth-1.8cm},0){%
    \hspace*{0.48cm}\rotatebox{90}{%
      \colorbox{gray8!44}{%
        \begin{minipage}{\paperheight}
          \sffamily
          \vspace*{0.4em}
          \centering
          \hspace*{\stretch{1}}
          \footnotesize{\textcolor{gray4}{some vertical text here along the pages}}
          \hspace*{\stretch{1}}
          \vspace*{0.4em}
        \end{minipage}%
      }%
    }% 
   }%
  }%
 }%
 {
  \AtPageLowerLeft{%
    \hspace*{0.48cm}\rotatebox{90}{%
      \colorbox{gray8!44}{%
        \begin{minipage}{\paperheight}
          \sffamily
          \vspace*{0.4em}
          \centering
          \hspace*{\stretch{1}}
           \footnotesize{\textcolor{gray4}{some vertical text here along the pages}}    
          \hspace*{\stretch{1}}
          \vspace*{0.4em}
        \end{minipage}%
      }%
    }%
   }%
 }%

}%
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\newpage{}
\section{Intro}
\newpage{}
\section{Methods}
\newpage{}

\end{document} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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.