使用 thmtools 为 amsthm 定理设计样式

使用 thmtools 为 amsthm 定理设计样式

我正在尝试对我的定义/示例等进行一些风格化,以便在完成后有一个更简单的概述。我特别想实现这一点:例子但我真的不知道如何实现它。我只能想到一个垂直拉伸的细框,与整个环境的左侧对齐,但由于我对 tex 还不太熟悉,所以无法实现它。

梅威瑟:

\pdfminorversion=7

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage{thmtools}
\usepackage{lipsum}

% Theorem styles
\newtheoremstyle{customDefinition}
    {}            % Space above, empty = `usual value'
    {}            % Space below
    {\itshape}    % Body font
    {}            % Indent amount (empty = no indent, \parindent = para indent)
    {\bfseries}   % Thm head font
    {}            % Punctuation after thm head
    {\newline}    % Space after thm head: \newline = linebreak
    {Definition \thmnumber{#2}\thmname{\hfill#1}}   % Thm head spec

\begin{document}
    \theoremstyle{customDefinition}
    \newtheorem{definition}{Matrix}[section]
    \begin{definition}
        \lipsum[2]
    \end{definition}
\end{document}

答案1

我建议此代码完全基于thmtoolsleftbar来自framed包的环境:

\pdfminorversion=7

\documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry} % showframe only for checking purpose. Remove for production.
\usepackage[svgnames]{xcolor}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{thmtools}
\usepackage{lipsum}

\usepackage{framed}
\colorlet{headcolour}{DarkOrange}
\colorlet{rulecolour}{DarkOrange}
\renewenvironment{leftbar}{%
  \def\FrameCommand{{\color{rulecolour}\vrule width 3pt} \hspace{10pt}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}

 \declaretheoremstyle[headfont=\sffamily\bfseries,%
 notefont=\sffamily\bfseries,%
 notebraces={}{},%
 headpunct=,%
 bodyfont=\sffamily\itshape,%
 headformat=\color{headcolour}\NAME~\NUMBER\hfill\NOTE\smallskip\linebreak,%
 preheadhook=\begin{leftbar},%
 postfoothook=\end{leftbar},%
 ]{customDefinition}
 \declaretheorem[style=customDefinition, numberwithin=section]{definition}

\begin{document}

\setcounter{section}{4}
    \begin{definition}[Matrix]
        \lipsum[2]
    \end{definition}

\end{document} 

在此处输入图片描述

相关内容