3

How to coloraate title of Listoffigures Listoftables Listofgraphes as image beloe This is my cood texenter image description here

\documentclass{report}

\usepackage{xcolor,graphicx,lipsum}
\usepackage{lipsum} % for  dummy text
\usepackage{float}
\usepackage{caption}



 % optional
 \DeclareCaptionFont{blue}{\bfseries\color{blue}}
 \captionsetup[graph]{labelfont=blue} 
\newfloat{graph}{tbp}{grp}
\floatname{graph}{Graph}


\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listof{graph}{List des graphs}

\newpage
\lipsum[1][1-4]
\begin{graph} [h]

 \caption{A float for a graph.}
 
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\lipsum[2][1-4]
\begin{graph}[h]
\centering (Another plot) \caption{Another  float for a graph.}
\end{graph}

\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\lipsum[3][1-4]
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\end{document}
2
  • Welcome to TeX.SE! have you asked this question an second time? It is better to edit the old question instead of asking a new question ...
    – Mensch
    Commented May 29 at 13:15
  • 1
    Instead of asking the same question again, you should edit your previous question and improve it.
    – cabohah
    Commented May 29 at 13:21

2 Answers 2

3

This would be very easy, if you'd switch from the standard report class report to the KOMA-Script report class scrreprt:

\documentclass[letterpaper,10pt,sfdefault=false,chapterprefix]{scrreprt}

\usepackage{xcolor,graphicx,lipsum}
\usepackage{lipsum} % for  dummy text
\usepackage{float}
\usepackage{caption}



 % optional
 \DeclareCaptionFont{blue}{\bfseries\color{blue}}
 \captionsetup[graph]{labelfont=blue} 
\newfloat{graph}{tbp}{grp}% Instead of using package float, you could here
\floatname{graph}{Graph}% also use the code shown in the third example.

\colorlet{chaptercolor}{black}
\addtokomafont{chapter}{\color{chaptercolor}}

\begin{document}
\tableofcontents
\colorlet{chaptercolor}{green}
\listoffigures
\colorlet{chaptercolor}{red!50!black!50}
\listoftables
\colorlet{chaptercolor}{blue!80!red!20}
\listof{graph}{List des graphs}

\colorlet{chaptercolor}{black}
\newpage
\lipsum[1][1-4]
\begin{graph} [h]

 \caption{A float for a graph.}
 
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\lipsum[2][1-4]
\begin{graph}[h]
\centering (Another plot) \caption{Another  float for a graph.}
\end{graph}

\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\lipsum[3][1-4]
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\end{document}

If you want to stay with standard class report, you could use an additional package, e.g., titlesec or sectsty to redefine the chapter headings:

\documentclass{report}

\usepackage{xcolor,graphicx,lipsum}
\usepackage{lipsum} % for  dummy text
\usepackage{float}
\usepackage{caption}
\usepackage{sectsty}

 % optional
 \DeclareCaptionFont{blue}{\bfseries\color{blue}}
 \captionsetup[graph]{labelfont=blue} 
\newfloat{graph}{tbp}{grp}% Instead of using package float, you could here
\floatname{graph}{Graph}% also use the code shown in the second example.

\colorlet{chaptercolor}{black}
\chapterfont{\color{chaptercolor}}

\begin{document}
\tableofcontents
\colorlet{chaptercolor}{green}
\listoffigures
\colorlet{chaptercolor}{red!50!black!50}
\listoftables
\colorlet{chaptercolor}{blue!80!red!20}
\listof{graph}{List des graphs}

\colorlet{chaptercolor}{black}
\newpage
\lipsum[1][1-4]
\begin{graph} [h]

 \caption{A float for a graph.}
 
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\lipsum[2][1-4]
\begin{graph}[h]
\centering (Another plot) \caption{Another  float for a graph.}
\end{graph}

\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\lipsum[3][1-4]
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\end{document}

or tocbasic to redefine the lists:

\documentclass{report}

\usepackage{xcolor,graphicx,lipsum}
\usepackage{lipsum} % for  dummy text
\usepackage{caption}

\usepackage{tocbasic}
\DeclareNewTOC[
  type=graph,
  name=Graph,
  listname=List de graphs,
  float=yes
]{grp}
\renewcommand*{\listoffigures}{\listoftoc[\textcolor{green}{\listfigurename}]{lof}}
\renewcommand*{\listoftables}{\listoftoc[\textcolor{red!90!black!50}{\listtablename}]{lot}}
\renewcommand*{\listofgraphs}{\listoftoc[\textcolor{red!40!blue!80}{List des graphs}]{grp}}
% optional
\DeclareCaptionFont{blue}{\bfseries\color{blue}}
\captionsetup[graph]{labelfont=blue}

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listofgraphs

\newpage
\lipsum[1][1-4]
\begin{graph} [h]

 \caption{A float for a graph.}
 
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\lipsum[2][1-4]
\begin{graph}[h]
\centering (Another plot) \caption{Another  float for a graph.}
\end{graph}

\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\lipsum[3][1-4]
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\end{document}

And you can also use hooks to change the color before the headings and add the reset to the beginning of the contents of the auxiliary files:

\documentclass{report}

\usepackage{xcolor,graphicx,lipsum}
\usepackage{lipsum} % for  dummy text
\usepackage{float}
\usepackage{caption}

 % optional
 \DeclareCaptionFont{blue}{\bfseries\color{blue}}
 \captionsetup[graph]{labelfont=blue} 
\newfloat{graph}{tbp}{grp}
\floatname{graph}{Graph}

\AddToHook{cmd/listoffigures/before}{\color{green}}
\addtocontents{lof}{\protect\normalcolor}

\AddToHook{cmd/listoftables/before}{\color{red!40!black!80}}
\addtocontents{lot}{\protect\normalcolor}

\newcommand*{\listofgraphs}{%
  \listof{graph}{\textcolor{blue!80!red!40}{List des graps}}%
}

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listofgraphs

\newpage
\lipsum[1][1-4]
\begin{graph} [h]

 \caption{A float for a graph.}
 
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\begin{graph} [h]

 \caption{A float for a graph.}
\end{graph}
\lipsum[2][1-4]
\begin{graph}[h]
\centering (Another plot) \caption{Another  float for a graph.}
\end{graph}

\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\begin{figure}
 \caption{A float for a graph.}
\end{figure}
\lipsum[3][1-4]
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\begin{table}
 \caption{A float for a graph.}
\end{table}
\end{document}

Maybe this last suggestion is more a kind of hack. But with the standard classes and without using a package like titlesec or sectsty it works.

Notes:

  • The used colors in the examples above are only examples. For information about how to setup the color you want, see the xcolor manual.
  • For a document in French I would also recommend the usage of \usepackage[french]{babel}. This would also change the defaults of the names used for the table of contents, the list of figures and the list of tables. If you want to change those defaults afterwards, please have a look into the babel manual.
2
  • Thank you soooooo much
    – walid
    Commented May 29 at 17:32
  • @walid “Sooooooo much” sounds, like you could consider to accept the answer by clicking to the hook. ;-) After reaching enough reputation, you can also vote for it. “Thank you” comments are not really needed.
    – cabohah
    Commented May 29 at 17:37
1

I'd use newfloat instead of float.

With this package, you will have \listofgraphs that internally uses \listoffigures, so we just need to patch two commands in order to pass a color to the related \chapter* command.

I also suggest to define color names, so as to avoid code duplication and possible mistakes.

\documentclass[a4paper]{report}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{newfloat}
\usepackage{xpatch}

% add possible color to the chapter heading
\let\listcolor\normalcolor
\xpatchcmd{\listoffigures}{\listfigurename}{\listcolor\listfigurename}{}{}
\xpatchcmd{\listoftables}{\listtablename}{\listcolor\listtablename}{}{}

\colorlet{figurecolor}{green!70!blue}
\colorlet{tablecolor}{red!70!black}
\colorlet{graphcolor}{blue!70!green}

\DeclareCaptionFont{figure}{\bfseries\color{figurecolor}}
\DeclareCaptionFont{table}{\bfseries\color{tablecolor}}
\DeclareCaptionFont{graph}{\bfseries\color{graphcolor}}
\DeclareFloatingEnvironment[
  fileext=grp,
  listname=List of graphs,
  name=Graph,
  placement=tbp,
]{graph}
\captionsetup[figure]{labelfont=figure}
\captionsetup[table]{labelfont=table}
\captionsetup[graph]{labelfont=graph}
\AddToHookNext{cmd/listoffigures/before}{\renewcommand{\listcolor}{\color{figurecolor}}}
\AddToHookNext{cmd/listoffigures/after}{\let\listcolor\normalcolor}
\AddToHookNext{cmd/listoftables/before}{\renewcommand{\listcolor}{\color{tablecolor}}}
\AddToHookNext{cmd/listoftables/after}{\let\listcolor\normalcolor}
\AddToHookNext{cmd/listofgraphs/before}{\renewcommand{\listcolor}{\color{graphcolor}}}
\AddToHookNext{cmd/listofgraphs/after}{\let\listcolor\normalcolor}


\begin{document}

\tableofcontents

\begingroup\let\clearpage\relax
\listoffigures
\listoftables
\listofgraphs
\endgroup

\clearpage

\begin{graph} [h]
\caption{A float for a graph.}
\end{graph}

\begin{figure}
\caption{A float for a figure.}
\end{figure}

\begin{table}
\caption{A float for a table.}
\end{table}

\end{document}

The \begingroup\let\clearpage\relax trick is just to make all lists in the same page. Remove it for your document along with the final \endgroup.

enter image description here

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .