# Add a command which allows to color some words

I would like to define a command \defi which allows to color words with one color (not necessarily the color of the picture below) : to color the word matrice, I just want to type \defi{matrice}.

Here is a starting code.

\documentclass[12pt,a4paper]{report}
\usepackage{amsfonts,amsmath,amssymb,graphicx,amsthm}
\usepackage[francais]{babel}
\usepackage{pifont} %bouni
\usepackage{fancybox} %pour faire l'encadrement
\usepackage[latin1]{inputenc}
\usepackage{verbatim}
\usepackage{color}
%\usepackage{hyperref}
\usepackage[final]{pdfpages} %pour inserer une page pdf
\usepackage{fancyhdr} % pagestyle
%---- Dimensions des marges ---
\usepackage{geometry}
\geometry{left=2cm,right=2cm,top=2cm,bottom=2cm}
%\usepackage{setspace}
%\onehalfspacing
%----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newtheorem{definition}{Définition}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{theorem}{Théorème}[section]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{definition}
\begin{itemize}
\item [(i)] Une matrice $A$ est un tableau rectangulaire
d'élèments de $\mathbb{R}$.
\item [(ii)] Elle est dite de taille $n \times p$ si le tableau
possède $n$ lignes et $p$ colonnes.
\item [(iii)] Les nombres du tableau sont appelès les coefficients de $A$.
\item [(vi)] Le coefficient situé à la $i$-éme ligne et à la $j$-éme colonne
est noté $a_{i,j}$.
\end{itemize}
\end{definition}

\end{document}

• You should look up what this means \newtheorem{definition}{Définition}[section] especially the [section] part. As for the other something like \newcommand\HL[1]{\emph{\textcolor{orange}{#1}}} (requires xcolor) Apr 23 at 9:57
• Related, as far as coloring: tex.stackexchange.com/questions/580936/…, unless of course you prefer \textcolor{orange}{\itshape matrice} for every instance. Also your question is really asking two completely unrelated questions (coloring, numbering). Best if you keep a question limited to a single issue. Apr 23 at 12:18
• @StevenB.Segletes Thanks for your comment. I don't understand how my question is closely related to the linked one? Apr 23 at 16:07
• @StevenB.Segletes I have edited my question as adviced Apr 23 at 16:14
• @StevenB.Segletes I hope that you can help me by an answer. Thanks in advance Apr 24 at 3:08

You can do as @daleif is suggesting. The default color is orange; another color can be selected as e.g. \defi[blue]{Bleu} for a text in blue. I also added \theoremstyle{definition} before defining the definition theorem-style.

\documentclass[12pt,a4paper]{report}

\usepackage{amsfonts,amsthm}
\usepackage{xcolor}
\usepackage[francais]{babel}

\theoremstyle{definition}
\newtheorem{definition}{Définition}

\newcommand{\defi}[2][orange]{\emph{\textcolor{#1}{#2}}}

\begin{document}

\begin{definition}
\begin{itemize}
\item [(i)] Une \defi{matrice} $A$ est un tableau rectangulaire
d'éléments de $\mathbb{R}$.
\item [(ii)] Elle est dite de \defi{taille} $n \times p$ si le
tableau possède $n$ lignes et $p$ colonnes.
\item [(iii)] Les nombres du tableau sont appelés les
\defi{coefficients} de $A$.
\item [(vi)] Le coefficient situé à la $i$-ème ligne et à la $j$-ème
colonne est noté $a_{i,j}$.
\end{itemize}
\end{definition}

\end{document}


• @Schüler write instead \newcommand{\defi}[2][blue]{\emph{\textcolor{#1}{#2}}} to get blue as the default color ` Apr 24 at 18:18