[Tex/LaTex] Verbatim frame latex with no waste

verbatim

I have a frame/boarder round my Verbatim environment however the frame is extended to the page side, thus alot of wasted space. The following is my code:

    \begin{Verbatim}[frame=single]
   s=0 
   for j = 1 : i -1 
      s = s + aij * akj
   end 
   aki = (aki - s) / aii 

    \end{Verbatim}

Best Answer

The Verbatim environment from the fancyvrb has not an options to do that.

But you can use the similar environment boxedverbatim from the moreverb package. Remember anyway to eliminate the spaces at the beginning of lines.

MWE

\documentclass{article}
\usepackage{moreverb}

\begin{document}

\begin{boxedverbatim}
s=0
for j = 1 : i -1
  s = s + aij * akj
end
aki = (aki - s) / aii
\end{boxedverbatim}

\end{document}  

Output

enter image description here

Related Question