GeneralHow to modify an environment created with Tcolorbox?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
abdelhakim
Posts: 5
Joined: Tue May 26, 2020 1:34 am

How to modify an environment created with Tcolorbox?

Post by abdelhakim »

Hello everyone . please help me to
  • change the name of the "proof" environment of the amsthm package which displays "Démonstration" to the name "preuve" written in bold!
  • enlarge the width of the part that contains the title in the image below!
Image
here is the latex code :

Code: Select all

\documentclass[12pt,a4paper]{report}

\usepackage{amsfonts}
\usepackage{fourier}
\usepackage{amssymb}
\usepackage[francais]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\renewcommand\qedsymbol{$\blacksquare$}

%==============================================================

\usepackage[usenames,dvipsnames]{color}
\usepackage[svgnames,dvipsnames]{xcolor}

%===============================================================

\usepackage{tcolorbox}
\tcbuselibrary{breakable} 

% =====  Environment "théorème"  ======================

\newtcolorbox[auto counter,number within=chapter]{thm}[1][]{%
	colback=green!10!white,colframe=green!20!white,fonttitle=\bfseries,coltitle=black,
	toprule=3pt,
	leftrule=2pt,
	rightrule=2pt,
	titlerule=0pt,
	title=Th\'eor\'eme.~\thetcbcounter,#1} 

%======== Environment  "Remarque " ====================

\newtcolorbox{rmk}[1][]{
	breakable,
	title=Remarque,
	colback=white,
	colbacktitle=green!20!white,
	coltitle=Black,
	fonttitle=\bfseries,
	bottomrule=0pt,
	toprule=0pt,
	leftrule=2pt,
	rightrule=0pt,
	titlerule=0pt,
	arc=0pt,
	outer arc=0pt,
	colframe=red   }	
%================================================================

\begin{document}
	\chapter{}
	\section{La fonction Gamma} 
	\begin{thm}
	Pour tout $x\in \mathbb{R}^{+*}$
	\begin{equation}
	\Gamma(x)= \lim_{k\rightarrow +\infty} \frac{k^{x}k!}{x(x+1)\ldots(x+k)}.
	\end{equation}
	\end{thm}
	\begin{proof}
	on consid\'ere .... \\ par suite \\ d'o\`u le r\'esultat.
	\end{proof}
	\begin{rmk}
		Le th\'eor\'eme pr\'ec\`edant est due aux deux math\'ematiciens Euler et Gauss.
	\end{rmk}	
\end{document}
thank you in advance
Last edited by abdelhakim on Wed Jul 01, 2020 5:14 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

How to modify an environment created with Tcolorbox?

Post by Bartman »

A suggestion to change the name of the proof and some other changes:

Code: Select all

\documentclass[12pt,a4paper]{report}
     
    \usepackage{fourier}
    \usepackage{amssymb}% loads amsfonts
    % A warning in log file calls francais deprecated.
    \usepackage[french]{babel}
    % Modern editors use UTF-8. Make a copy of your files for security 
    % before changing their encoding and the option.
    \usepackage[latin1]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{amsthm}
    % color is integrated within xcolor.
    % The option usenames is not longer needed.
    \usepackage[svgnames,dvipsnames]{xcolor}
    \usepackage{tcolorbox}
    
    \tcbuselibrary{breakable} 
     
     \renewcommand\qedsymbol{$\blacksquare$}
     
     \addto\captionsfrench{% because of babel
        \renewcommand{\proofname}{\normalfont\bfseries Preuve}%
     }
     
    % =====  Environment "théorème"  ======================
     
    \newtcolorbox[auto counter,number within=chapter]{thm}[1][]{%
    	colback=green!10!white,
    	colframe=green!20!white,
    	fonttitle=\bfseries,
    	coltitle=black,
    	toprule=3pt,
    	leftrule=2pt,
    	rightrule=2pt,
    	titlerule=0pt,
    	title=Th\'eor\'eme.~\thetcbcounter,#1} 
     
    %======== Environment  "Remarque " ====================
     
    \newtcolorbox{rmk}[1][]{
    	breakable,
    	title=Remarque,
    	colback=white,
    	colbacktitle=green!20!white,
    	coltitle=Black,
    	fonttitle=\bfseries,
    	bottomrule=0pt,
    	toprule=0pt,
    	leftrule=2pt,
    	rightrule=0pt,
    	titlerule=0pt,
    	arc=0pt,
    	outer arc=0pt,
    	colframe=red   }	
    %================================================================
     
    \begin{document}
    	\chapter{Chapitre}
    	\section{La fonction Gamma} 
    	\begin{thm}
    	Pour tout $x\in \mathbb{R}^{+*}$
    	\begin{equation}
    	\Gamma(x)= \lim_{k\rightarrow +\infty} \frac{k^{x}k!}{x(x+1)\ldots(x+k)}.
    	\end{equation}
    	\end{thm}
    	\begin{proof}
    	on consid\'ere \dots \\ par suite \\ d'o\`u le r\'esultat.
    	\end{proof}
    	\begin{rmk}
    	Le th\'eor\'eme pr\'ec\`edant est due aux deux math\'ematiciens 
    	Euler et Gauss.
    	\end{rmk}	
    \end{document}
abdelhakim
Posts: 5
Joined: Tue May 26, 2020 1:34 am

How to modify an environment created with Tcolorbox?

Post by abdelhakim »

I really appreciate your help!
one more question please !
how to change the framework of the theorem to have something similar to that: i mean a red line surrounding the theorem : Image
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

How to modify an environment created with Tcolorbox?

Post by Bartman »

Add the skins library to your preamble and add the following changes to the options list of the \newtcolorbox command for the thm environment:

Code: Select all

\newtcolorbox[auto counter,number within=chapter]{thm}[1][]{%
    enhanced,% added
    frame style={draw=red, ultra thick},% added
    colback=green!10!white,
    colframe=green!20!white,
    fonttitle=\bfseries,
    coltitle=black,
    toprule=3pt,
    leftrule=2pt,
    rightrule=2pt,
    titlerule=0pt,
    title=Th\'eor\'eme.~\thetcbcounter,#1}
abdelhakim
Posts: 5
Joined: Tue May 26, 2020 1:34 am

How to modify an environment created with Tcolorbox?

Post by abdelhakim »

Thank you verry much, i really appreciate your help ! :)
Post Reply