Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}%
}%
\MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}
{\endMakeFramed}
\setlength{\FrameSep}{5pt}


\begin{document}
\lipsum[3]
\begin{leftbar}
\lipsum[3]
\end{leftbar}
\lipsum[3]
\end{document}
share|improve this question

1 Answer 1

up vote 8 down vote accepted

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}%
}%
\MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}
{\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}

enter image description here

share|improve this answer
    
You are my hero :) It works great! Thanks so much –  user16110 Jun 29 '12 at 20:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.