[Tex/LaTex] Formatting – title with underline and box around paragraph

formattingframedparagraphssectioning

Can you help me please with formatting?

I like this format:
example formating

How can I define this title with grey underline (width of all page)? Font is sans serif (Arial). And how can I make grey box around some paragraph?

Best Answer

You can use the titlesec package to customize the formatting for the sectional unit headings; the mdframed or the framed packages give you the possibility to get framed text; a little example:

\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\colorlet{mycolor}{gray!50}

\titleformat{\section}
  {\normalfont\sffamily\Large\fontfamily{phv}\selectfont}
  {\thesection.}{.5em}{}[\vspace{.2ex}\color{mycolor}\titlerule]

\newmdenv[linecolor=mycolor,skipabove=\topsep,skipbelow=\topsep,
leftmargin=-5pt,rightmargin=-5pt,
innerleftmargin=5pt,innerrightmargin=5pt]{mybox}

\begin{document}

\section*{Title}

\lipsum[2]
\begin{mybox}
\lipsum[2]
\end{mybox}

\end{document}

enter image description here

I wasn't sure about the desired width for the frame, so here's another option:

\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\colorlet{mycolor}{gray!50}

\titleformat{\section}
  {\normalfont\sffamily\Large\fontfamily{phv}\selectfont}
  {\thesection.}{.5em}{}[\vspace{.2ex}\color{mycolor}\titlerule]

\newmdenv[linecolor=mycolor,skipabove=\topsep,skipbelow=\topsep]{mybox}

\begin{document}

\section*{Title}

\lipsum[2]
\begin{mybox}
\lipsum[2]
\end{mybox}

\end{document}

enter image description here

Related Question