1

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

enter image description here

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}

projetmbc
  • 13,315
Schüler
  • 886
  • 2
    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) – daleif Apr 23 '21 at 09:57
  • 3
    Related, as far as coloring: https://tex.stackexchange.com/questions/580936/automatic-text-highlighting-based-on-a-dictionary, 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. – Steven B. Segletes Apr 23 '21 at 12:18
  • @StevenB.Segletes Thanks for your comment. I don't understand how my question is closely related to the linked one? – Schüler Apr 23 '21 at 16:07
  • @StevenB.Segletes I have edited my question as adviced – Schüler Apr 23 '21 at 16:14
  • In my cited answer, \setsepchar{apple||banana} is used to define the words you want "always colored". While the syntax is slightly different than you seek (and I could make them the same syntax), the similarity of defining words you always want colored is what the two questions have in common. – Steven B. Segletes Apr 23 '21 at 19:29
  • 1
    @StevenB.Segletes I hope that you can help me by an answer. Thanks in advance – Schüler Apr 24 '21 at 03:08

1 Answers1

1

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}

enter image description here

user94293
  • 4,254
  • Thanks for the answer. When I replace \newcommand{\defi}[2][orange]{\emph{\textcolor{#1}{#2}}} by \newcommand{\defi[blue]{Bleu}} it does not work. Could you please help me if I want to change the color? Thanks a lot – Schüler Apr 24 '21 at 12:26
  • @Schüler write instead \newcommand{\defi}[2][blue]{\emph{\textcolor{#1}{#2}}} to get blue as the default color ` – user94293 Apr 24 '21 at 18:18