# Alignment in the Leftbar Environment. Is Rightbar possible?

In this question I asked about changing the indentation (on the left) in the leftbar environment. I've got things nicely lined up (with the bar outside of the text field), but there is a little bit of space on the right side that I'd like to remove. Also, how does one convert a leftbar into a rightbar?

\documentclass{article}
\usepackage[centering]{geometry}
\usepackage{lipsum}

\newlength{\leftbarwidth}
\setlength{\leftbarwidth}{3pt}
\newlength{\leftbarsep}
\setlength{\leftbarsep}{10pt}

\usepackage{xcolor}
\usepackage{framed}
\renewenvironment{leftbar}[1][\hsize]
{%
\def\FrameCommand
{%

{\hspace{-7pt} \color{black} \vrule width 2pt}%
\hspace{0pt}%must no space.
\fboxsep=\FrameSep\colorbox{white}%
}%
}
{\endMakeFramed}
\setlength{\FrameSep}{5pt}

\begin{document}
\lipsum[3]
\begin{leftbar}
\lipsum[3]
\end{leftbar}
\lipsum[3]
\end{document}

-
–  cmhughes Apr 3 '12 at 18:21

If using mdframed instead of framed is an option, then you can easily control all the attributes of your frames; in particular, you can easily achieve a righbar style. In the following example I used mdframed features two define two new environments rightbar and mdleftbar and I also used your leftbar environment for comparison purposes:

\documentclass{article}
\usepackage[centering]{geometry}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{mdframed}
\usepackage{lipsum}

\newlength{\leftbarwidth}
\setlength{\leftbarwidth}{3pt}
\newlength{\leftbarsep}
\setlength{\leftbarsep}{10pt}

\renewenvironment{leftbar}[1][\hsize]
{%
\def\FrameCommand
{%
{\hspace{-7pt} \color{black} \vrule width 2pt}%
\hspace{0pt}%must no space.
\fboxsep=\FrameSep\colorbox{white}%
}%
}
{\endMakeFramed}
\setlength{\FrameSep}{5pt}

\newmdenv[topline=false, leftline=false, bottomline=false,%
linewidth=2pt, innerleftmargin=0pt, rightmargin=-4pt,%
innerrightmargin=5pt, skipabove=8pt, skipbelow=8pt]{rightbar}

\newmdenv[topline=false, rightline=false, bottomline=false,%
linewidth=2pt, innerrightmargin=0pt, leftmargin=-4pt,%
innerleftmargin=5pt, skipabove=8pt, skipbelow=8pt]{mdleftbar}

\begin{document}
\lipsum[2]
\begin{leftbar}
\lipsum[2]
\end{leftbar}
\lipsum[2]
\begin{mdleftbar}
\lipsum[2]
\end{mdleftbar}
\lipsum[2]
\begin{rightbar}
\lipsum[2]
\end{rightbar}

\end{document}


-
You are my hero :) It works great! Thanks so much –  user16110 Jun 29 '12 at 20:27