[Tex/LaTex] Draw red box around verse

colorframedverse

This is a follow-up question to: How to center a verse horizontally

I am using the solution given by @Herbert. Is there a way to put a color box around selected few verses I desire?

Best Answer

You can use the mdframed package to put a box the full width, or specify the margins to have it indented:

enter image description here

\documentclass{article}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage[framemethod=tikz,xcolor=true]{mdframed}
\usepackage{varwidth}

\newenvironment{Verse}
  {\center\varwidth{\linewidth}}
  {\endvarwidth\endcenter}    

\begin{document}

\lipsum[1]

\begin{mdframed}[
    tikzsetting={draw=red,ultra thick},skipabove=5pt,
]
\begin{Verse}
foo bar\\
baz
\end{Verse}
\end{mdframed}
\begin{mdframed}[
    tikzsetting={draw=red,ultra thick},skipabove=5pt,
    rightmargin=2cm,leftmargin=2cm
]
\begin{Verse}
foo bar\\
baz
\end{Verse}
\end{mdframed}
\end{document}