4

How do I control/remove the indentation automatically generated in the \leftbar environment?

\documentclass[11pt,letterpaper]{amsbook}
\usepackage{xcolor}
\definecolor{lightgray}{gray}{0.90}

\newtheorem{theorem}{Theorem}

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

    {\color{black}\vrule width 3pt}%
    \hspace{0pt}%must no space.
    \fboxsep=\FrameSep\colorbox{lightgray}%
}%
\MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}
{\endMakeFramed}

\begin{document}

\begin{leftbar}
\begin{theorem}
Fun Math
\end{theorem}
\end{leftbar}
\end{document}
lockstep
  • 250,273
user02138
  • 1,801
  • 3
  • 19
  • 27

1 Answers1

5

The indentation is caused by \Framesep and the width of the left bar with the value of 3pt. Here \setlength{\FrameSep}{0pt} and \hspace{-3pt} in \FrameCommand are used to show that:

\documentclass[11pt,letterpaper]{amsbook}
\usepackage{xcolor}
\definecolor{lightgray}{gray}{0.90}
\newtheorem{theorem}{Theorem}
\usepackage{framed}
\renewenvironment{leftbar}[1][\hsize]
{% 
\def\FrameCommand 
{%

    {\hspace{-3pt}\color{black}\vrule width 3pt}%
    \hspace{0pt}%must no space.
    \fboxsep=\FrameSep\colorbox{lightgray}%
}%
\MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}
{\endMakeFramed}
\setlength{\FrameSep}{0pt}
\begin{document}
\begin{leftbar}
\begin{theorem}
Fun Math
\end{theorem}
\end{leftbar}
\begin{theorem}
Fun Math
\end{theorem}
\end{document}

framed theorem

Stefan Kottwitz
  • 231,401