1

I want to use an image to numbering sections and subsection in the table of content when working with Beamer. I used the code

\defbeamertemplate{subsection in toc}{imageSec}{\small\includegraphics[height=1.6ex]{bullet_bb_round.png}}
\setbeamertemplate{subsection in toc}[imageSec]

but it does not work for me. I got the bullet but the name of subsection does not appear next the bullet.

Here is a MWE:

\documentclass[11 pt]{beamer}
\usetheme{default}
%\usepackage[T1]{fontenc}
\usepackage{lmodern} % load a font with all the characters
\usepackage[no-math]{fontspec}
%\usepackage[frenchb]{babel}
%\usepackage[babel=true]{csquotes} % csquotes va utiliser la langue définie dans babel
%\frenchbsetup{StandardLists=true}
\usepackage{amsmath}%loads amsmath that should go before unicode-math
%\usepackage{unicode-math}
\usepackage{euler-math}
%\setmathfont[math-style=upright]{Neo Euler}
%\setmathfont[range=\mathbb]{texgyrepagella-math.otf}
%\setmathfont[range=\mathcal]{STIXTwoMath-Regular.otf}%à utiliser pour le "L" uniquement!
\newcommand{\diff}{\mathop{}\!{\mathrm d}} % better than using \,{\mathrm d}
%\setmathfont[range=\mathbin]{STIXGeneral}%pour intercal
%===========TIKZ========%
\usepackage{tikz}
\usetikzlibrary{decorations}
%\usetikzlibrary{arrows, decorations.markings}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shapes.callouts}
\usepackage{xparse}
%\tikzstyle{vecArrow} = [thick, decoration={markings,mark=at position
%   1 with {\arrow[semithick]{open triangle 60}}},
%   double distance=1.4pt, shorten >= 5.5pt,
%   preaction = {decorate},
%   postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]
%\tikzstyle{innerWhite} = [semithick, white,line width=1.4pt, shorten >= 4.5pt]
%===========Bull======%
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
    },
}

\NewDocumentCommand{\mycallout}{r<> O{opacity=0.8,text opacity=1} m m}{%
\tikz[remember picture, overlay]\node[align=center, text width=3cm,
#2,visible on=<#1>, rounded corners,
draw,rectangle callout,anchor=pointer,callout relative pointer={(-1,-0.5)}]
at (#3) {#4};
}
\NewDocumentCommand{\mycalloutSym}{r<> O{opacity=0.8,text opacity=1} m m}{%
\tikz[remember picture, overlay]\node[align=center, text width=2.5cm,
#2,visible on=<#1>, rounded corners,
draw,rectangle callout,anchor=pointer,callout relative pointer={(-1,0.5)}]
at (#3) {#4};
}
\NewDocumentCommand{\mycalloutG}{r<> O{opacity=0.8,text opacity=1} m m}{%
\tikz[remember picture, overlay]\node[align=center, text width=2.5cm,
#2,visible on=<#1>, rounded corners,
draw,rectangle callout,anchor=pointer,callout relative pointer={(1,-0.5)}]
at (#3) {#4};
}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=-0.5ex] \node (#1) {};}
%=======Grille==========
\newcommand{\grille}{
 \begin{tikzpicture}[overlay,remember picture]
  \begin{scope}[shift={(current page.south west)}]
    \draw[gray!50] (0,0) grid[step=2mm] (current page.north east);
   \draw[red!50] (0,0) grid[step=1cm] (current page.north east);
      \draw (0.2,1) node {1};
     \draw (0.2,2) node {2};
     \draw (0.2,3) node {3};
     \draw (0.2,4) node {4};
     \draw (0.2,5) node {5};
     \draw (0.2,6) node {6};
     \draw (0.2,7) node {7};
     \draw (0.2,8) node {8};
     \draw (0.2,9) node {9};
     \draw (1,0.5) node {1};
     \draw (2,0.5) node {2};
     \draw (3,0.5) node {3};
     \draw (4,0.5) node {4};
     \draw (5,0.5) node {5};
     \draw (6,0.5) node {6};
     \draw (7,0.5) node {7};
     \draw (8,0.5) node {8};
     \draw (9,0.5) node {9};
     \draw (10,0.5) node {10};
     \draw (11,0.5) node {11};
     \draw (12,0.5) node {12};
   \end{scope}
 \end{tikzpicture}
 }
%=======================%
%%%%%%%%%%
% ===FONTS ===%
%%%%%%%%%%

\usefonttheme{professionalfonts}
%% XeLaTeX fonts: (comment out if you don't use XeLaTeX)
%% For advanced fonts: access local OS X fonts      
%% This template uses typical OS X and Adobe fonts
\defaultfontfeatures{Mapping=tex-text}  % This seems to be important for mapping glyphs properly
%%%%%%%%%%%%%%%%%

%\setmainfont{SetFireToTheRain.ttf}
%\setsansfont{SetFireToTheRain.ttf}

%Default fonts%
\setmainfont{Meta-Italic-Regular.ttf}
\setsansfont{Meta-Italic-Regular.ttf}

%\setmainfont{HUMASNLI.ttf}         % Beamer ignores "main font" in favor of sans font
%\setsansfont{HUMASNLI.ttf}         % This is the font that beamer will use by default
%\setbeamerfont{frametitle}{family=\fontspec{Chalkboard}}

%%%%%%%%%%%%%%%%%%%%%%%%%
%========Frame Number Customization=====%
%%%%%%%%%%%%%%%%%%%%%%%%%%

\defbeamertemplate{footline}{centered page number}
{%
  \hspace*{\fill}%
  \usebeamercolor[white]{page number in head/foot}%
  \usebeamerfont{page number in head/foot}%
  \insertframenumber%
  \hspace*{\fill}\vskip2pt%
}
\setbeamertemplate{footline}[centered page number]
\setbeamertemplate{navigation symbols}{} 

% To change margins for all slides
\setbeamersize{text margin left=0.25cm,text margin right=0.25cm}

%\newcommand{\handwriting}{\fontspec{augie}} % From Emerald City, free font
% \newcommand{\handwriting}{}   % If you prefer no special handwriting font or don't have augie

%%%%%%%%%%%%%%%%%%%%%%%%
% =======Usual LaTeX Packages======== %
%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{graphicx}
\usepackage{stackrel}
%\usepackage{mathtools}
\usepackage{bbm}  
%\usepackage{answers}
%\usepackage{lipsum}
\usepackage{multicol}
\usepackage{xfrac}
%\usepackage{bbding}
%\usepackage{enumitem}
%\usepackage{stmaryrd}
%\SetSymbolFont{stmry}{bold}{U}{stmry}{m}{n}
%\usepackage[tikz]{bclogo}
%\usetikzlibrary{patterns,shapes,backgrounds,calc,arrows}


%%%%%%%%%%%%%%%%%%%%%%%
% ========Couleurs=================%.
%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{Rose}{RGB}{253, 108, 158}
\definecolor{Magenta}{RGB}{255, 0, 255}
\definecolor{Orange}{RGB}{250, 164, 1}
\definecolor{Bleu}{RGB}{38, 196, 236}
\definecolor{Vert}{RGB}{159, 232, 85}   
\definecolor{Jaune}{RGB}{255, 255, 107}
\definecolor{Argent}{RGB}{186, 186, 186}
\definecolor{Blanc_ecru}{RGB}{254, 254, 224}
\definecolor{Blanc_creme}{RGB}{253, 241, 184}
\definecolor{Gris_souris}{RGB}{158, 158, 158}
\definecolor{Noir_de_fumee}{RGB}{19, 14, 10}
\definecolor{Ardoise}{RGB}{48, 48, 48}
\definecolor{Fumee}{RGB}{187, 210, 225}
\definecolor{Aigue-marine}{RGB}{121, 248, 248}
\definecolor{Menthe_a_leau}{RGB}{84, 249, 141}
\definecolor{Ventre_de_biche}{RGB}{233, 201, 177}
\definecolor{Heliotrope}{RGB}{223, 115, 255}
\definecolor{DefPers}{RGB}{122, 150, 172}
\definecolor{AlertM}{RGB}{255,127,66}
%%%%%%%%%%%%%%%%%%
%=======Apparence=========%
%%%%%%%%%%%%%%%%%%
\setbeamertemplate{frametitle}[default][center]
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{alerted text}{fg=AlertM}
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{title}{fg=white}
\setbeamercolor{section in toc}{fg=white}
\graphicspath{{images/}}    % Put all images in this directory. Avoids clutter.
\setbeamertemplate{background canvas}{\includegraphics [width=\paperwidth]{blackboard_bk.pdf}}



%\setbeamerfont{section in toc}{family=\fontspec{HUMASNMI.TTF}}
%%%%%%%%%%%%%%%%%%%%%%%
%=====Environnements personnels======%
%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tcolorbox} 
\tcbuselibrary{theorems}

\tcbset{%Théorème
myboxT/.style={
 standard jigsaw, 
 opacityback=0,
 opacitybacktitle=0,
 coltitle=Rose,
 coltext=white,
 colframe=Rose,
 boxrule=1.5pt,
 titlerule=0pt,
 arc=5pt,
 middle=0pt,
 boxsep=0.1cm,
 title={\strut#1}
  }
}

\tcbset{%Définition
myboxD/.style={
 standard jigsaw, 
 opacityback=0,
 opacitybacktitle=0,
 coltitle=DefPers,
 coltext=white,
 colframe=DefPers,
 boxrule=1.5pt,
 titlerule=0pt,
 arc=5pt,
 middle=0pt,
 boxsep=0.1cm,
 title={\strut#1}
  }
}



%\newtcolorbox{boxThm}[1][Th\'eor\`eme\,:]{%Théorème
%standard jigsaw, 
%opacityback=0,
%opacitybacktitle=0,
%coltitle=Rose,
%coltext=white,
%colframe=Rose,
%boxrule=1.5pt,
%titlerule=0pt,
%arc=5pt,
%middle=0pt,
%boxsep=0.1cm,
%title={\strut#1}
%}
\tcbset{%Proposition
myboxP/.style={
standard jigsaw, 
opacityback=0,
opacitybacktitle=0,
coltitle=Bleu,
coltext=white,
colframe=Bleu,
boxrule=1.5pt,
titlerule=0pt,
arc=5pt,
middle=0pt,
boxsep=0.1cm,
title={\strut#1}
}
}

\tcbset{%Corollaire
myboxC/.style={
standard jigsaw, 
opacityback=0,
opacitybacktitle=0,
coltitle=Orange,
coltext=white,
colframe=Orange,
boxrule=1.5pt,
titlerule=0pt,
arc=5pt,
middle=0pt,
boxsep=0.1cm,
title={\strut#1}
}}

\tcbset{%Lemme
myboxL/.style={
standard jigsaw, 
opacityback=0,
opacitybacktitle=0,
coltitle=Vert,
coltext=white,
colframe=Vert,
boxrule=1.5pt,
titlerule=0pt,
arc=5pt,
middle=0pt,
boxsep=0.1cm,
title={\strut#1}
}}

\tcbset{%hypothèse
myboxN/.style={
standard jigsaw, 
opacityback=0,
opacitybacktitle=0,
coltitle=white,
coltext=white,
colframe=white,
boxrule=1.5pt,
titlerule=0pt,
arc=5pt,
middle=0pt,
boxsep=0.1cm,
title={\strut#1}
}}




\newtcbtheorem{boxThm}{Th\'eor\`eme}{myboxT}{thm}
\newtcbtheorem{boxDef}{D\'efinition}{myboxD}{def}
%\newtcbtheorem{boxLem}{Lemme}{myboxT}{lem}
\newtcbtheorem{boxCor}{Corollaire}{myboxC}{cor}
\newtcbtheorem{boxProp}{Proposition}{myboxP}{prop}
\newtcbtheorem{boxLem}{Lemme}{myboxL}{lem}
\newtcbtheorem{boxHyp}{Hypoth\`ese}{myboxH}{hyp}
%=================LaTeXDraw==========
\usepackage{wrapfig}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{epsfig}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\usepackage{pst-3dplot}
\usepackage{pst-solides3d}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%======symboles et commandes usuelles=========%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\input{./codes}

%========================%
\title{R\'egularisation de l'\'equation int\'egrale volumique en th\'eorie de diffraction \'electromagn\'etique}
\author{Hamdi SAKLY\\ \small{Facult\'e des sciences de Bizerte}}
\date{ICSTPDEDSM'2023}
%\institute{Facult\'e des sciences de Bizerte}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%========================CUSTOM TOC====================%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\defbeamertemplate{subsection in toc}{bullets}{%
  \leavevmode
  \parbox[t]{1em}{\textbullet\hfill}%
  \parbox[t]{\dimexpr\textwidth-1em\relax}{\inserttocsubsection}\par}
\defbeamertemplate{section in toc}{sections numbered roman}{%
  \leavevmode%
  \MakeUppercase{\romannumeral\inserttocsectionnumber}.\ %
  \inserttocsection\par}
  
  \defbeamertemplate{subsubsection in toc}{subsubsections numbered}
{\leavevmode\leftskip=3em%
 \rlap{\hskip-3em\inserttocsectionnumber.\inserttocsubsectionnumber.\inserttocsubsubsectionnumber}%
 \inserttocsubsubsection\par}
  
\setbeamertemplate{section in toc}[sections numbered roman]

%==========================%
%=========ICI=============%
%==========================%
\defbeamertemplate{subsection in toc}{imageSec}{\small\includegraphics[height=1.6ex]{bullet_bb_round.png}}
\setbeamertemplate{subsection in toc}[imageSec]

%=====les deux commandes=======%
%\setbeamertemplate{subsection in toc}[bullets]
\setbeamertemplate{subsubsection in toc}[subsubsections numbered]
%====================================================%
\setbeamertemplate{section in toc shaded}[default][70]
\setbeamertemplate{subsection in toc shaded}[default][70]


%\AtBeginSection[]{
%  \begin{frame}<beamer>{Plan}
%  \setbeamercolor{section in toc shaded}{fg=Ardoise}
%  \setbeamercolor{section in toc}{fg=white}
%  \setbeamercolor{subsection in toc shaded}{fg=Ardoise}
%   \setbeamercolor{subsection in toc}{fg=white}
%     
%  \tableofcontents[currentsection,sectionstyle=show/show,
% subsectionstyle=hide/show/hide]
%% \addtocounter{framenumber}{-1}
%  \end{frame}
%}



%====Celle là======%
%\AtBeginSubsection[]
%{
%\setbeamercolor{section in toc shaded}{fg=Ardoise}
%\setbeamercolor{section in toc}{fg=white}
% \setbeamercolor{subsection in toc shaded}{fg=Ardoise}
%  \setbeamercolor{subsection in toc}{fg=white}
%  \begin{frame}<beamer>{Plan}
%    \tableofcontents[currentsection,currentsubsection]
%  \end{frame}
%}
%=================Item Customization====%
%==========Item=============%
\defbeamertemplate{itemize item}{image}{\small\includegraphics[height=1.6ex]{bullet_bb_round.png}}
\setbeamertemplate{itemize item}[image]
%\newcommand*\subi{\item[\includegraphics[height=1.6ex]{item2.png}]}
%==========Subitem===============%
\defbeamertemplate{itemize subitem}{image_deux}{\small\includegraphics[height=1.6ex]{item3.png}}
\setbeamertemplate{itemize subitem}[image_deux]
%==========Subsubitem================%
\defbeamertemplate{itemize subsubitem}{image_trois}{\small\includegraphics[height=1.6ex]{item4.png}}
\setbeamertemplate{itemize subsubitem}[image_trois]
%=====Enumerate========================%
\setbeamercolor{enumerate item}{fg=white}
     \begin{document}
     \tikzstyle{every picture}+=[remember picture]
     \begin{frame}[c]{Plan} \tableofcontents \end{frame} \section{Section 1} \subsection{Subsection 1} \subsection{Subsection2}
 \end{document}
3
  • Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for the users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Nov 21, 2023 at 11:03
  • @samcarter_is_at_topanswers.xyz I added a MWE.
    – SAKLY
    Nov 21, 2023 at 11:19
  • @ SAKLY Thanks! Nov 21, 2023 at 11:21

1 Answer 1

0

You need to include \inserttocsection in your section in toc template. This macro will insert the section title:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{section in toc}{
  \leavevmode%
  \includegraphics[height=1.6ex]{example-image-duck}
  \inserttocsection\par%
}
\makeatother

\begin{document}

\section{title}
\begin{frame}
  \tableofcontents
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

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