左页左侧有垂直边框,右页右侧有垂直边框,带有 \AddToShipoutPicture

左页左侧有垂直边框,右页右侧有垂直边框,带有 \AddToShipoutPicture

我有以下代码,可在页面上添加一些垂直边框,但它始终位于同一侧(即左侧)。因此,对于twoside文档来说,它看起来不太好。

在变化较少的情况下,如何使其出现在右页的右侧,以及左页的左侧?

\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

我找到了一个解决方案,但是我遇到了一个问题(我无法使用我的 MWE 重现该问题,因此它一定与其他包发生冲突),footmisc我必须将这个包放在序言中的新包之前:

\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} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

相关内容