6

I have created a tcolorbox environment to write proofs.

Here is my code:

\usepackage{tcolorbox}
  \tcbuselibrary{most}

\newtcolorbox{proof}{ fonttitle=\bfseries, enhanced, top=0mm, boxrule=0pt,frame empty, borderline west={4pt}{0pt}{blue}, coltitle=blue, colback=white, sharp corners, title=Proof }

\begin{proof} Let's show that girls are Evil. \begin{adjustwidth}{5mm}{0mm} Girls require time and money \begin{equation} girls = time \times money \end{equation} Time is money \begin{equation} time = money \end{equation} So girls are money squared: \begin{equation} girls = money^2 \end{equation} Money is the root of all evil \begin{equation} money = \sqrt{evil} \end{equation} So, girls are evil: \begin{equation} girls = \left(\sqrt{evil}\right)^2 = evil \end{equation} \end{adjustwidth} We have shown that girls are Evil. \end{proof} % From https://www.onlinemathlearning.com/funny-math-proofs.html

Now, I would like that a blue square is automatically added at the end of the proof (at the very end of the last line) like here. I do not know how to specify this in the proof environment definition.

Julien M.
  • 145
  • Try the examples given in doc of tcolorbox v4.42, sec. 17.4 Using other theorem environments with tcolorbox. – muzimuzhi Z Dec 25 '20 at 10:57
  • I think adding the after upper={\qed} option to \newtcolorbox with the \usepackage{amsthm} package will do what you want. I would also suggest you not use the name proof as your envuronment name. Also, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that sets up the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Dec 25 '20 at 10:58
  • Maybe wrap the words with \text – Someone Dec 25 '20 at 16:32

2 Answers2

7

Add the lines

\usepackage{amssymb}% defines \blacksquare
\AtEndEnvironment{proof}{\null\hfill\textcolor{blue}{$\blacksquare$}}

to your preamble; replace \blacksquare by \square if the symbol is too massive.

For LaTeX versions older than 2020/10/01, you need the etoolbox package before using \AtEndEnvironment.

enter image description here

\documentclass{article}
\usepackage{amssymb}
\AtEndEnvironment{proof}{\null\hfill\textcolor{blue}{$\blacksquare$}}%
\usepackage{changepage}
\usepackage{tcolorbox}
  \tcbuselibrary{most}

\newtcolorbox{proof}{ fonttitle=\bfseries, enhanced, top=0mm, boxrule=0pt,frame empty, borderline west={4pt}{0pt}{blue}, coltitle=blue, colback=white, sharp corners, title=Proof }

\begin{document} \begin{proof} Let's show that girls are Evil. \begin{adjustwidth}{5mm}{0mm} So, girls are evil: \begin{equation} girls = \left(\sqrt{evil}\right)^2 = evil \end{equation} \end{adjustwidth} We have shown that girls are Evil. \end{proof} \end{document}

Adapted from this answer

gernot
  • 49,614
6

Using the ntheorem package, you have the automatic placement of the end-of-proof symbol at the end of the last line, including the cases when the last line is an equation:

\documentclass{article}
\usepackage{fourier} 
 \usepackage{amsmath, amssymb}
\usepackage[thmmarks, amsmath, thref]{ntheorem}
\usepackage{changepage} 
\usepackage{tcolorbox}
\tcbuselibrary{most}

\theoremstyle{nonumberbreakn} \theoremheaderfont{\scshape\color{blue}} \theoremseparator{:\smallskip} \theorembodyfont{\upshape} \theoremsymbol{\ensuremath{\color{blue}\blacksquare}} \newtheorem{proof}{Proof}

\tcolorboxenvironment{proof}{ fonttitle=\bfseries, enhanced, top=0mm, boxrule=0pt,frame empty, borderline west={4pt}{0pt}{blue}, coltitle=blue, colback=white, sharp corners }

\begin{document}

\begin{proof} Let's show that girls are Evil. \begin{adjustwidth}{5mm}{0mm} Girls require time and money \begin{equation} girls = time \times money \end{equation} Time is money \begin{equation} time = money \end{equation} So girls are money squared: \begin{equation} girls = money^2 \end{equation} Money is the root of all evil \begin{equation} money = \sqrt{evil} \end{equation} So, girls are evil: \begin{equation} girls = \left(\sqrt{evil}\right)^2 = evil \end{equation} \end{adjustwidth} % We have shown that girls are Evil. \end{proof}

\end{document}

enter image description here

Bernard
  • 271,350
  • Thanks. In the code given in my first message, I have chosen to have a line break after the "proof" label. To keep this line break using your code, one has to use the nonumberbreak theoremstyle in place of nonumberplain. – Julien M. Dec 25 '20 at 14:59
  • It seems I misunderstood the exact layout. I'll fix that in a moment. – Bernard Dec 25 '20 at 15:47