GeneralSidebar over 2 Pages on the outside of the Page

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Andreas Knafl
Posts: 11
Joined: Mon Jun 20, 2016 11:28 pm

Sidebar over 2 Pages on the outside of the Page

Post by Andreas Knafl »

Hey guys!
I'm new in Latex and I need some Help:
I want to create an environment or a command, drawing me a sidebar beside my text, equation or graphic on the outside of my page.
I've found a solution to draw a sidebar, which continues over Pages, and I'm also able to change the side of the bar:

Code: Select all

\documentclass[a5paper,10pt,twoside,]{scrbook}
\usepackage[left=2cm,right=1.5cm,top=1cm,bottom=0.5cm,includeheadfoot]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{lipsum}

\usepackage{framed} 

\usepackage{mdframed} 
\newmdenv[topline=false,rightline=false,bottomline=false,leftline=true]{leftb}
\newmdenv[topline=false,rightline=true,bottomline=false,leftline=false]{rightb}

\newlength{\leftbarwidth}
\setlength{\leftbarwidth}{2pt}
\newlength{\leftbarsep}
\setlength{\leftbarsep}{5pt}

\usepackage{ifthen}

\newenvironment{Beispiel}
	{
	\begin{leftb}
	\begin{addmargin}[0cm]{0cm}
	}
	{
	\end{addmargin}
	\end{leftb}
	}

\begin{document}

\begin{Beispiel}
\lipsum[1-7]
\end{Beispiel}

\end{document}

I also created a conditional, allowing me to change the side of the sidebar depending on wheter the page is odd or not

Code: Select all

\usepackage{ifthen}
\newcounter{pl}
\newcounter{pl2}
\newenvironment{Testd}
	{
	\stepcounter{pl}\label{pl-\thepl}%
     \ifthenelse{\isodd{\pageref{pl-\thepl}}}%
		{\begin{leftb}}
		{\begin{rightb}}
	}
	{
	\stepcounter{pl2}\label{pl2-\thepl2}%
     \ifthenelse{\isodd{\pageref{pl2-\thepl2}}}%
		{\end{leftb}}
		{\end{rightb}}	
The reason why my code doesn't work is the following:
When the Text goes over two Pages, the environment will get in trouble because it want to end the environment with the wrong \end

Does anybody got a solution? Sorry for my english and thanks for Help :D

EDIT:
So far, I try to figure out a way to draw a vertical line with tikz behind the text. My Question is: Is there an option to use the start of my environment (\begin{Beispiel}) as the first height-position-point of my line an the end of my environment as the second height-position-point ?

Once again:
My problem is:
I want to get a line on the outer side of my text (book)

Recommended reading 2024:

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

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

Post Reply