内边距中的垂直文本问题

内边距中的垂直文本问题

使用以下代码时,我无法正确设置版权声明和垂直标题。我需要修复两个问题:

  1. 垂直文本应保留在灰色区域内(目前如此),但文本基线应正好位于纸张边缘 0.5 英寸处。目前,它离纸张边缘太近了。

  2. 我想从代码中完全删除垂直灰带(因为它存在打印问题)。

那么我该如何修复这个代码呢?

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{eso-pic}
\usepackage{xcolor}
\usepackage{showframe}

\newlength{\distance}
\setlength{\distance}{0.0in}
\newlength{\rulethickness}
\setlength{\rulethickness}{0.5in}
\newlength{\ruleheight}
\setlength{\ruleheight}{\paperheight}
\newlength{\xoffset}
\newlength{\yoffset}
\setlength{\yoffset}{0pt}

\AddToShipoutPicture{%
    \setlength\fboxsep{0pt}%
    \ifodd\value{page}%
        \setlength{\xoffset}{\distance}%
    \else
        \setlength{\xoffset}{\dimexpr\paperwidth-\rulethickness-\distance}%
    \fi
    \AtPageLowerLeft{%
        \put(\LenToUnit{\xoffset},\LenToUnit{\yoffset}){%
        \colorbox{lightgray}{\parbox[b][\ruleheight][c]{\rulethickness}{%
        \centering
        \ifodd\value{page}%
            \rotatebox[origin=cB]{90}{\color{red}{\large{\normalfont\textsc{Copyright notice}}}}%
        \else
            \rotatebox[origin=cB]{90}{\color{blue}{\huge{\normalfont\textsc{Some Title}}}}%
        \fi
    }}}}%
}

\begin{document}

Test
\newpage
Another page

\end{document}

我必须承认,我不太清楚这段代码是如何工作的,尤其是对于灰色带,我至今无法将其移除(除非将其颜色改为白色)。预览一下这段代码的作用,以及红色显示的问题:

在此处输入图片描述

答案1

这是一个解决方案:我在旋转的文本之前或之后添加了一个长度为 2.5em 的隐形规则,具体取决于页面是偶数还是奇数:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{eso-pic}
\usepackage{xcolor}
\usepackage{showframe}

\newlength{\distance}
\setlength{\distance}{0.0in}
\newlength{\rulethickness}
\setlength{\rulethickness}{0.5in}
\newlength{\ruleheight}
\setlength{\ruleheight}{\paperheight}
\newlength{\xoffset}
\newlength{\yoffset}
\setlength{\yoffset}{0pt}

\AddToShipoutPicture{%
    \setlength\fboxsep{0pt}%
    \ifodd\value{page}%
        \setlength{\xoffset}{\distance}%
    \else
        \setlength{\xoffset}{\dimexpr\paperwidth-\rulethickness-\distance}%
    \fi
    \AtPageLowerLeft{%
        \put(\LenToUnit{\xoffset},\LenToUnit{\yoffset}){%
        \colorbox{lightgray!50}{\parbox[b][\ruleheight][c]{\rulethickness}{%
        \centering
        \ifodd\value{page}%
           \rule{2.5em}{0pt}\rotatebox[origin=cB]{90}{\color{red}{\large{\normalfont\textsc{Copyright notice}}}}%
        \else
            \rotatebox[origin=cB]{90}{\color{blue}{\huge{\normalfont\textsc{Some Title}}}}\rule{2.5em}{0pt}%
        \fi
    }}}}%
}

\begin{document}

Test
\newpage
Another page

\end{document} 

在此处输入图片描述

答案2

我认为这是我正在寻找的解决方案。 可以以某种方式改进吗?(预览图与 Bernard 的解决方案中的预览图相同,但没有灰色带):

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{eso-pic}
\usepackage{xcolor}
\usepackage{showframe}

\newlength{\xoffset}

\AddToShipoutPicture{%
    \ifodd\value{page}%
        \setlength{\xoffset}{0in}%
    \else
        \setlength{\xoffset}{\dimexpr\paperwidth-0.5in}%
    \fi
    \AtPageLowerLeft{%
        \put(\LenToUnit{\xoffset},\LenToUnit{0in}){%
        \parbox[b][\paperheight][c]{0.5in}{%
        \ifodd\value{page}%
            \flushright
            \rotatebox[origin=cB]{90}{\color{red}{\large{\normalfont\textsc{Copyright notice}}}}%
        \else
            \rotatebox[origin=cB]{90}{\color{blue}{\huge{\normalfont\textsc{Some Title}}}}%
        \fi
    }}}%
}

\begin{document}

Test
\newpage
Another page

\end{document}

相关内容