TransWikia.com

Removing indent/newline before and after leftbar

TeX - LaTeX Asked by Pa Dalton on July 14, 2021

Im writing a summary of my lectures and encountered a problem.
I would like to insert a vertical left bar near the important theorems I have to know.
What I found so far is the following:

documentclass[a4paper,landscape]{report}
usepackage[a4paper,margin=0.5cm,landscape]{geometry}

usepackage{blindtext}
usepackage{framed}

renewenvironment{leftbar}{%
    nobreak
    defFrameCommand{{vrule width 1pt} hspace{3pt} }%
    MakeFramed {advancehsize-width FrameRestore}}%
{endMakeFramed}

begin{document}
    blindtext
    blindtext
    begin{leftbar}
    blindtext
    end{leftbar}
    blindtext
end{document}

I already set the thickness of the line to 1 px because it was too big for my liking.

Here an example: Just plain textenter image description here

Becomes indented and makes a newline before and after the leftbar:enter image description here

What should I do to remove the indents and the new lines?

Many thanks in advice for your answers!

One Answer

To remove the indentation at the start of the leftbar environment you need to add a noindent to the begin-code. (And an ignorespaces to protect against the space following }). For the indentation after the environment you can use the @endparenv kernel macro. The vertical spacing around the environment is controlled by the length OuterFrameSep, which you can redefine to zero (but leave it some ability to stretch).

documentclass{report}

usepackage{blindtext}
usepackage{framed}

renewenvironment{leftbar}{%
   OuterFrameSep=0ex plus .8ex
   defFrameCommand{{vrule width 1pt} hspace{3pt} }%
   MakeFramed {advancehsize-width FrameRestore}
   noindentignorespaces
  }{%
   endMakeFramed
   csname@endparenvendcsname
}

begin{document}

blindtext
begin{leftbar}
blindtext
end{leftbar}
Some text here to show no indentation.
begin{leftbar}
Other lorem ipsum stuff.
end{leftbar}

Here you emph{do} have an indentation because of the additional empty line.

end{document}

enter image description here

Careful with the spaces: right now

defFrameCommand{{vrule width 1pt} hspace{3pt} }

gives you an horizontal space of 3pt plus two spaces: see

a{vrule width 1pt} hspace{3pt} bpar
a{vrule width 1pt}hspace{3pt} bpar
a{vrule width 1pt}hspace{3pt}b

enter image description here

I would get rid of the two spaces and increase the 3pt to something you like.

Correct answer by campa on July 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP