5

I'm trying to highlight some parts (paragraphs) in a document. For this I want to use a box, with the paragraph number hanging out into the left margin. However, I don't really know how to pull this off! Can someone help out? This is what I have so far. I'm using scrbook, with pdflatex to compile it. The issue is that first, the indentation of the text is not correct (you can see, it's a bit too far indented), and I'd really like that paragraph sign to be right-aligned and in the top (which it isn't right now). I hope someone can help fix this, or maybe suggest a package for this that I wasn't able to find? I'll also gladly take stylistic suggestions!

Here's the minimal example code:

\documentclass[paper=a5, parskip=half, 12pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{roboto}
\usepackage{mathptmx}

\begin{document}
    Vi Frederik den Niende, af Guds Nåde Konge til Danmark, de Venders og Goters, Hertug til Slesvig, Holsten, Stormarn, Ditmarsken, Lauenborg og Oldenborg, Gør vitterligt: I overensstemmelse med bestemmelserne i § 94 i Danmarks Riges Grundlov af 5. juni 1915 med ændringer af 10. september 1920 har rigsdagen 2 gange vedtaget, og folketingsvælgerne ved en den 28. maj 1953 afholdt folkeafstemning godkendt, hvorefter Vi nu ved Vort allerhøjeste samtykke stadfæster DANMARKS RIGES GRUNDLOV 

    \hspace{-1cm}\colorbox{gray!10!white}{\parbox{1cm}{\sffamily\bfseries § 8}\parbox{\textwidth}{ Bestemmelser angående regeringens førelse i tilfælde af kongens umyndighed, sygdom eller fraværelse fastsættes ved lov. Er der ved tronledighed ingen tronfølger, vælger folketinget en konge og fastsætter den fremtidige arvefølge.}}
\end{document}

And here is what it looks like:

Failed attempt at creating a paragraph box

Thanks a lot in advance!

1 Answer 1

8

You could make use of the tcolorbox package as shown in this example:

\documentclass{scrbook}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}


\newtcolorbox{myBox}{%
  sidebyside,
  sidebyside align=top,
  lower separated=true,
  lefthand width=2em,
  arc=0pt,
  left=8pt,right=2pt,top=2pt,bottom=2pt,
  fontupper=\Large\bfseries,
  skin=bicolor,
  colback=black!60, 
  colframe=black!60,
  colupper=white,
  colbacklower=black!5,
  boxrule=0.5pt,
  sidebyside gap=5pt,
  width=\textwidth+2em+13pt,
  enlarge left by=-2em-13pt
}

\begin{document}


\begin{myBox}
\raisebox{-1ex}{§8}
\tcblower
\lipsum[1]
\end{myBox}

\lipsum[5]
\end{document}

enter image description here

Colors, font sizes, margins, ... of the box (that was inspired by this answer) can of course be changed to suit your needs.

1
  • Thanks a lot, this is much better than me rolling my own implementation. And more customizable, too. I only had to add \usepackage[T1]{fontenc} and \usepackage[utf8]{inputenc} to get this to work – otherwise the § wouldn't show up.
    – xfbs
    Commented Jul 8, 2018 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .