Code: Select all
\documentclass[10pt]{article}
\usepackage{xcolor}
%to create framed box that can be splitted across page.
\usepackage{framed}
\renewenvironment{leftbar}[1][\hsize]{%
\def\FrameCommand{{\color{red}\vrule width 5pt}\hspace{0pt}\fboxsep=\FrameSep\colorbox{cyan!50}}%
\MakeFramed {\hsize#1\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\newenvironment{Highlight}%
{%
\begin{leftbar}[\linewidth]%
\noindent\small%
}%
{%
\end{leftbar}%
}
\begin{document}
\begin{verbatim}
\begin{Highlight}
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
\end{Highlight}
\end{verbatim}
\begin{Highlight}
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
\end{Highlight}
\noindent\textcolor{red}{ Note: The first row starts with a space.}
\vspace{1cm}
\begin{verbatim}
\begin{Highlight}%
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
\end{Highlight}
\end{verbatim}
\begin{Highlight}%
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
The lazy brown fox jumps quickly over the hotdog.
\end{Highlight}
\noindent\textcolor{red}{ Note: To remove the unnecessary space, I must put \% at the end of opening tag.}
\vspace{1cm}
\noindent\textcolor{blue}{\bf\large Question: Is there a better way to remove the unnecessary space without having to put \% every time I use the environment?}
\end{document}
OUTPUT and explanation :

Thank you in advance.
yoyoimut