2

I am trying to get my "example" environment to look this:

enter image description here

with the two boxes before the word "Example". Can you help me get this effect?

Here is some code:

\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}
2

You can replace \ensuremath{\blacksquare} with \ensuremath{\square\raise0.2em\hbox to 0.2em{\hss$\blacksquare$}} to create the two boxes.

\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}

enter image description here

1

I think the easiest way is to put the boxes into the theorem title and draw them with 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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.