mdframed 和 titlesec 之間的錯誤

mdframed 和 titlesec 之間的錯誤

編輯:我使用的版本titlesec

titlesec.sty 2011/12/15 v2.10.0 切片標題


我用來mdframed定義盒子和類似定理的環境。當我加載包時titlesec,垂直對齊出現問題。

存在 bug 的 MWE

這是一個已載入的 MWE titlesec

\documentclass{article}
\usepackage{titlesec} % This is the cause of the wrong alignment
\usepackage{mdframed}

\newmdenv[%
innerleftmargin = 0pt,
innerrightmargin = 0pt,
innertopmargin = 0pt,
innerbottommargin = 0pt,
leftmargin = 0pt,
rightmargin = 0pt,
topline = false,
bottomline = false,
leftline = false,
rightline = true
]{myBox}

\mdfdefinestyle{myFramedTheoremStyle}{%
linewidth=0pt,
innertopmargin=-1pt,
innerbottommargin=8pt,
innerleftmargin=8pt,
innerrightmargin=8pt,
skipabove=10pt,
backgroundcolor=yellow}

\mdtheorem[style=myFramedTheoremStyle]{theo}{Theorem}

\begin{document}

\begin{myBox}
\section{test}
test
\begin{theo}
test
\end{theo}
\end{myBox}

\section{test}
test
\begin{theo}
Test
\end{theo}
\end{document}

在此輸入影像描述

MWE 應該是什麼樣子

沒有titlesec加載,結果如下:

在此輸入影像描述

我的問題

有辦法修復該錯誤嗎?我大量使用mdframedtitlesec只需要以下幾行

\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\large\bfseries}{\thesubsection}{1em}{}
\titlespacing*{\section} {0pt}{0ex plus 10ex minus -3.5ex}{-0.5ex plus .2ex}
\titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

感謝您的幫助。


我可能會放棄\section*{...}(而且titlesec;我不使用\section{},我只使用它的加星號版本)並將其替換為具有良好大小和格式的文本,但如果有人找到如何修復大的問題,那也很棒!

不管怎樣,既然我發現了這個錯誤,我認為在這裡引用它是件好事。

答案1

使用最新版本titlesec(2016/03/21 v2.10.2)和mdframed(2013/07/01 1.9b),您的MWE可以正常運作。

相關內容