结合 extract 和 tcolorbox

结合 extract 和 tcolorbox

我正在格式化我的课堂笔记,并使用\tcolorboxenvironmentfromtcolorbox包中的prooffromamsmath为我的校样设置了新的格式。这是代码

\documentclass[12pt, a4paper, report]{memoir}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{breakable}

\tcolorboxenvironment{proof}{% 'proof' from 'amsthm'
    blanker,breakable,left=5mm,
    before skip=10pt,after skip=10pt,
    borderline west={1mm}{0pt}{red}
}

\begin{document}
    \begin{proof}
        $ $\newline
        This is a proof.
    \end{proof}
\end{document}

它按预期进行编译,构建了以下内容

平均能量损失

然而,后来我使用了该extract软件包,虽然代码没有出现任何警告或错误,编译也同样顺利,但tcolorbox格式从我的原始文件中消失了,证明又回到了通常的证明样式格式,但在软件包创建的amsmath新文件中运行良好。所以我的原始代码停止了它所做的工作,但副本运行良好。proofsextract

在这种情况下为什么不一起extract合作呢?tcolorbox

这是之前的代码,添加了extract

\documentclass[12pt, a4paper, report, oneside, reqno]{memoir}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{breakable}

\tcolorboxenvironment{proof}{% 'proof' from 'amsthm'
    blanker,breakable,left=5mm,
    before skip=10pt,after skip=10pt,
    borderline west={1mm}{0pt}{red}
}

\usepackage[active, copydocumentclass=true, generate=proofs, extract-env={proof}]{extract} 

\begin{extract}
    \usepackage[utf8]{inputenc}
    \usepackage[english]{babel}
    \usepackage{amsmath,amsthm,amssymb}
    \usepackage{tcolorbox}
    \tcbuselibrary{skins}
    \tcbuselibrary{breakable}

    \tcolorboxenvironment{proof}{% 'proof' from 'amsthm'
        blanker,breakable,left=5mm,
        before skip=10pt,after skip=10pt,
        borderline west={1mm}{0pt}{red}
    }   
\end{extract}


\begin{document}
    \begin{proof}
        $ $\newline
        This is a proof.
    \end{proof}
\end{document}

这是最后一次构建的打印件

在此处输入图片描述

答案1

简单的解决方法:将tcolorbox东西移到后面extract

证明

\documentclass[12pt, a4paper, report, oneside, reqno]{memoir}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm,amssymb}

\usepackage[active, copydocumentclass=true, generate=proofs, extract-env={proof}]{extract} 
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{breakable}

\tcolorboxenvironment{proof}{% 'proof' from 'amsthm'
    blanker,breakable,left=5mm,
    before skip=10pt,after skip=10pt,
    borderline west={1mm}{0pt}{red}
}

\begin{extract}
    \usepackage[utf8]{inputenc}
    \usepackage[english]{babel}
    \usepackage{amsmath,amsthm,amssymb}
    \usepackage{tcolorbox}
    \tcbuselibrary{skins}
    \tcbuselibrary{breakable}

    \tcolorboxenvironment{proof}{% 'proof' from 'amsthm'
        blanker,breakable,left=5mm,
        before skip=10pt,after skip=10pt,
        borderline west={1mm}{0pt}{red}
    }   
\end{extract}


\begin{document}
    \begin{proof}
        $ $\newline
        This is a proof.
    \end{proof}
\end{document}

相关内容