Page LayoutAdding a vertical copyright into the margin

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Adding a vertical copyright into the margin

Post by Cham »

I added a gray vertical band inside the inner margin, using the following code (MWE code) :

Code: Select all

\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}

% Code to add a vertical gray band in the inner margin :
\usepackage{eso-pic}
\definecolor{colorMarge}{RGB}{242,242,245}
\newlength{\distance}
\setlength{\distance}{0.0in} % 0.5in
\newlength{\rulethickness}
\setlength{\rulethickness}{0.5in} % 1pt
\newlength{\ruleheight}
\setlength{\ruleheight}{11in} % Longueur de la ligne
\newlength{\xoffset}
\newlength{\yoffset}
\setlength{\yoffset}{0.5\dimexpr\paperheight-\ruleheight}

\AddToShipoutPicture{%
	\ifodd\value{page}%
		\setlength{\xoffset}{\distance}%
	\else
		\setlength{\xoffset}{\dimexpr\paperwidth-\rulethickness-\distance}%
	\fi
	\AtPageLowerLeft{\put(\LenToUnit{\xoffset},\LenToUnit{\yoffset}){\color{colorMarge}\rule{\rulethickness}{\ruleheight}}}%
}

\begin{document}

Test

\newpage
Another page

\end{document}
But then, I would like to add a name, title or short text, in vertical orientation, in white, and in the middle of that gray band. How should I do this ? Any idea ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Adding a vertical copyright into the margin

Post by Cham »

I just found that adding the following code to the previous MWE adds a vertical text line in the gray band, but it's not properly centered inside. Also, there's a slight offset of the "Document Title".

Code: Select all

\AddToShipoutPicture{%
	\AtPageLowerLeft{\put(\LenToUnit{\xoffset},\LenToUnit{\yoffset}){%
	 \ifodd\value{page}%
		\rotatebox[origin=l]{90}{\color{gray}{Document Title}}%
	\else
		\rotatebox[origin=r]{-90}{\color{gray}{Copyright Notice}}%
	\fi
	}}%
}
How should I fix that code ?
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Adding a vertical copyright into the margin

Post by rais »

Cham wrote:I just found that adding the following code to the previous MWE adds a vertical text line in the gray band,
actually, there's nothing in that code providing a \rotatebox command.
graphicx and rotating packages come to mind.
Cham wrote: but it's not properly centered inside.
I don't see any \centering or similar attempt to actually center anything here.
Cham wrote: Also, there's a slight offset of the "Document Title".
The reference point for rotating is not at the bottom of the text, more like at the height of letter x. In the code below, I've added `B' for baseline to the origin option(s).

I don't think it wise to have text in the inner margin with different orientation, but that's up to you.

Code: Select all

\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}

% Code to add a vertical gray band in the inner margin :
\usepackage{eso-pic}
\usepackage{graphicx}
\definecolor{colorMarge}{RGB}{242,242,245}
\newlength{\distance}
\setlength{\distance}{0.0in} % 0.5in
\newlength{\rulethickness}
\setlength{\rulethickness}{0.5in} % 1pt
\newlength{\ruleheight}
\setlength{\ruleheight}{\paperheight} % Longueur de la ligne
\newlength{\xoffset}
\newlength{\yoffset}
\setlength{\yoffset}{0pt} %{0.5\dimexpr\paperheight-\ruleheight}

\AddToShipoutPicture{%
  \setlength\fboxsep{0pt}% no additional frame for \colorbox
  \ifodd\value{page}%
    \setlength{\xoffset}{\distance}%
  \else
    \setlength{\xoffset}{\dimexpr\paperwidth-\rulethickness-\distance}%
  \fi
  \AtPageLowerLeft{%
    \put(\LenToUnit{\xoffset},\LenToUnit{\yoffset}){%
      \colorbox{colorMarge}{%
        \parbox[b][\ruleheight][b]{\rulethickness}{%
          \centering
          \ifodd\value{page}%
            \rotatebox[origin=lB]{90}{\color{gray}{\strut Document Title}}%
          \else
            \rotatebox[origin=rB]{-90}{\color{gray}{\strut Copyright Notice}}%
          \fi
        }%
      }%
    }%
  }%
}
\begin{document}

Test
\newpage
Another page

\end{document}
would be an idea.;-)

KR
Rainer
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Adding a vertical copyright into the margin

Post by Cham »

Ah ! Thanks, it's working.

How do you vertically center the text lines ?

And what is the \strut command ?
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Adding a vertical copyright into the margin

Post by rais »

Cham wrote: How do you vertically center the text lines ?
You can replace the inner alignment for the \parbox---the second ---with [c]. In that case, you may want to replace the origin for the two \rotatebox commands to `cB', too.
Cham wrote: And what is the \strut command ?

\strut is basically a box of zero width with a height of 70% and a depth of 30% of the current baseline skip.
In this case, I just used it to give the `Document Title' some depth (it's supposed to ensure the horizontal position (after rotation) won't change, whether you're using text with depth, e.g., the `g', `p', and `y' in `Copyright' all have depth---or not).

KR
Rainer
Post Reply