1

Since it is impossible, or at least really hacky, to split a command over two arguments, I'd rather use a macro with a new environment to achieve a faster typesetting experience and consistent look.

I intend to put a box around a minipage which is smaller/narrower than the columnwidth that it is placed in, hence my attempt at the new environment.

Then I just ran into the next problem: the box set with mdframed does not seem to adhere to the columnwidth.

=> Why does the first box have that faulty width? Did I make an error or did I overlook something?

(Ironically, the faulty version has the nicer vertical spacing before the line with the orange text. This is something that I wanted to fine-tune later-on, but apparently already did so inadvertently.)

Screenshot of MWE

enter image description here

MWE

\documentclass[
11pt,
a4paper,
]
{scrartcl}

\usepackage{
lmodern,
multicol,
blindtext,
mdframed,
}

\usepackage[svgnames]{xcolor}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\newenvironment{envstuff}[2]{%
\begin{center}
\begin{mdframed}
\begin{minipage}[t]{0.9\columnwidth}\sffamily
\centering
\textcolor{orange}{\textbf{Something:}}~{#1}
\par\addvspace{-0.8ex}%
\rule{0.98\textwidth}{0.1pt}\par\addvspace{1ex}
\begin{minipage}[t]{0.98\columnwidth}\small\sffamily
{#2}}
{\end{minipage}
\end{minipage}
\end{mdframed}
\end{center}}

\listfiles

\begin{document}
\begin{center}\huge
Title stuff
\end{center}

\begin{multicols*}{2}
\section{Word}

\begin{envstuff}
{Words}{There really are words.
And then some.
AAaaaa bbbb cccc.
}
\end{envstuff}

{\centering
\fbox{
\begin{minipage}[t]{0.9\columnwidth}\sffamily
\centering
\textcolor{orange}{\textbf{Something:}}~{Words}
\par\addvspace{-0.8ex}%
\rule{0.98\textwidth}{0.1pt}\par\addvspace{1ex}
\begin{minipage}[t]{0.98\columnwidth}\small\sffamily
There really are words.
And then some.
AAaaaa bbbb cccc.
\end{minipage}
\end{minipage}}\par}


\blindtext[1]

\end{multicols*}
\end{document}
3
  • As far as I can tell from the documentation, a mdframed's default width is the available \linewidth, which is why your first box is exactly as wide as the column it is placed inside of. To overcome this, you can use userdefinedwidth.
    – leandriis
    Mar 27, 2021 at 20:12
  • 2
    Better use tcolorbox instead of mdframed. It is much more powerful. Mar 28, 2021 at 8:09
  • @UlrikeFischer Oooh. Yes, it is! Thank you for the tip! :)
    – henry
    Mar 28, 2021 at 10:04

1 Answer 1

1

I guess, the following is closer to the expected output:

enter image description here

\documentclass[
11pt,
a4paper,
]
{scrartcl}

\usepackage{
lmodern,
multicol,
blindtext,
mdframed,
}

\usepackage[svgnames]{xcolor}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\newenvironment{envstuff}[2]{%
\centering
\begin{mdframed}[userdefinedwidth=0.95\columnwidth, align=center, innerleftmargin=6pt, innerrightmargin=6pt]
\begin{minipage}[t]{\linewidth}\sffamily
\centering
\textcolor{orange}{\textbf{Something:}}~{#1}
\par\addvspace{-0.8ex}%
\rule{0.98\textwidth}{0.1pt}\par\addvspace{1ex}
\begin{minipage}[t]{\linewidth}\small\sffamily
{#2}}
{\end{minipage}
\end{minipage}
\end{mdframed}
}



\begin{document}
\begin{center}\huge
Title stuff
\end{center}

\begin{multicols*}{2}
\section{Word}

\begin{envstuff}
{Words}{There really are words.
And then some.
AAaaaa bbbb cccc.
}
\end{envstuff}

\blindtext[1]

\end{multicols*}
\end{document}
1
  • I did expect that kind of output. But boy, is that width-usage confusing (for me personally). I will manage somehow, not sure yet if I use that code. But thank you, it solved the question.
    – henry
    Mar 27, 2021 at 20:22

You must log in to answer this question.

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