如何在 mdframed 环境中使文本居中?

如何在 mdframed 环境中使文本居中?

我想在mdframed环境中自动居中文本。以下不起作用

\documentclass[a4paper]{article}
\usepackage[tikz]{mdframed}

\newmdenv
[innerleftmargin = 4mm,
innerrightmargin = 4mm,
innertopmargin = 4mm,
innerbottommargin = 4mm,
middlelinewidth = 0.3mm,
linecolor = darkgray,
font=\itshape,
align=center,
roundcorner = 0.5cm]
{important}

\begin{document}
\begin{important}
Test
\end{important}
\end{document}

答案1

这里是:

\documentclass[a4paper]{article}
\usepackage[tikz]{mdframed}
\usepackage[showframe]{geometry}
\usepackage{etoolbox}
\newmdenv
[innerleftmargin = 4mm,
innerrightmargin = 4mm,
innertopmargin = 4mm,
innerbottommargin = 4mm,
middlelinewidth = 0.3mm,
linecolor = darkgray,
font=\itshape,
align=center,
roundcorner = 0.5cm]
{important}
\newenvironment{Important}{\important\centering}{\endimportant}

\begin{document}

\begin{Important}
Test
\end{Important}

\end{document} 

在此处输入图片描述

相关内容