文档标题周围的框架,mdframed 错误

文档标题周围的框架,mdframed 错误

我使用 在文档标题周围添加了一个框架mdframed。文档可以正确编译和显示,但一直出现以下错误:

Something's wrong--perhaps a missing \item. \end

您对这种情况有什么想法吗?以下是正在使用的语法:

\begin{document}

\begin{mdframed}
\maketitle
\end{mdframed}

%Body text here

\end{document}

mdframed初始化为:

\usepackage[framemethod=default]{mdframed}
\mdfdefinestyle{MyFrame}{%
    linecolor=black,
    outerlinewidth=2pt,
    %roundcorner=20pt,
    innertopmargin=4pt,
    innerbottommargin=4pt,
    innerrightmargin=4pt,
    innerleftmargin=4pt,
    leftmargin = 4pt,
    rightmargin = 4pt
    %backgroundcolor=gray!50!white}
}

谢谢!

答案1

加载titling并使用\maketitlehookx命令进入和离开mdframed环境是没有问题的:

\documentclass[11pt, svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{garamondx}
\usepackage{verse}
\usepackage{titling}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{MyFrame}{%
    linecolor=Tomato,
    outerlinewidth=2,
    roundcorner=10pt,
    innertopmargin=15pt,
    innerbottommargin=4pt,
    innerrightmargin=4pt,
    innerleftmargin=4pt,
    leftmargin = 4pt,
    rightmargin = 4pt,
    backgroundcolor=WhiteSmoke
}
 \author{Edward Lear}
 \title{The Quangle Wangle’s Hat}
 \date{(n.\,d.)}

\renewcommand{\maketitlehooka}{\begin{mdframed}[style = MyFrame]}
\renewcommand{\maketitlehookd}{\end{mdframed}\vspace{5ex}}
\begin{document}

\maketitle
\settowidth{\versewidth}{For his Hat was a hundred and two feet wide,}
\begin{verse}[\versewidth]
\begin{altverse}
  On the top of the Crumpetty Tree\\
      The Quangle Wangle sat,\\
But his face you could not see,\\
      On account of his Beaver Hat.\\
For his Hat was a hundred and two feet wide,\\
With ribbons and bibbons on every side\\
And bells, and buttons, and loops, and lace,\\
So that nobody ever could see the face\\
            Of the Quangle Wangle Quee.
\end{altverse}
\end{verse}

\end{document} 

在此处输入图片描述

相关内容