具有两个盒子的示例环境

具有两个盒子的示例环境

我试图让我的“示例”环境看起来像这样:

在此处输入图片描述

在“示例”一词前有两个框。你能帮我实现这个效果吗?

以下是一些代码:

\documentclass[11pt,fleqn,table]{book}
\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\definecolor{ocre}{RGB}{0,173,239}

%======================================================================================
%  EXAMPLE ENVIRONMENT
%======================================================================================

\newtheorem{exampleT}{Example}[chapter]
\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}

\makeatletter
\newtheoremstyle{blacknumexocresq}
{5pt}
{5pt}
{\normalfont}
{} 
{\small\bf\sffamily}
{\;}
{0.25em}
{\small\sffamily{\textcolor{ocre}{\tiny\ensuremath{\blacksquare}}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% 
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}
\makeatother

\theoremstyle{blacknumexocresq}
\newtheorem{exampleM}{Example}[chapter]

\renewenvironment{example}{\begin{exampleM}}{\hfill{\textcolor{ocre}{\tiny\ensuremath{\blacksquare}}}\end{exampleM}}

\begin{document}

\chapter{This is where the example is}
\begin{example}
This is where the example will take place
\end{example}

\end{document}

答案1

您可以替换\ensuremath{\blacksquare}\ensuremath{\square\raise0.2em\hbox to 0.2em{\hss$\blacksquare$}}创建两个框。

\documentclass[11pt,fleqn,table]{book}
\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\definecolor{ocre}{RGB}{0,173,239}

%======================================================================================
%  EXAMPLE ENVIRONMENT
%======================================================================================

\newtheorem{exampleT}{Example}[chapter]
\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}

\makeatletter
\newtheoremstyle{blacknumexocresq}
{5pt}
{5pt}
{\normalfont}
{} 
{\small\bf\sffamily}
{\;}
{0.25em}
{\small\sffamily{\color{ocre}\tiny\ensuremath{\square\raise0.2em\hbox to 0.2em{\hss$\blacksquare$}}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% 
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}
\makeatother

\theoremstyle{blacknumexocresq}
\newtheorem{exampleM}{Example}[chapter]

\renewenvironment{example}{\begin{exampleM}}{\hfill{\textcolor{ocre}{\tiny\ensuremath{\blacksquare}}}\end{exampleM}}

\begin{document}

\chapter{This is where the example is}
\begin{example}
This is where the example will take place
\end{example}

\end{document}

在此处输入图片描述

答案2

我认为最简单的方法是将框放入定理标题中并用 tikz 绘制它们。

\documentclass{book}
\usepackage{amsthm}
\usepackage{tikz}
\newcommand{\boxes}{%
\begin{tikzpicture}
    \draw [black] (0,0) rectangle (1.2ex,1.2ex);%
    \fill [black] (0.4ex,0.4ex) rectangle (1.6ex,1.6ex);%
\end{tikzpicture}
}
\newtheorem{example}{\boxes Example}[chapter]

\begin{document}

\chapter{This is where the example is}
\begin{example}
This is where the example will take place
\end{example}

\end{document}

相关内容