3

I have a series of tcolorboxes, and i used the \thetcbcounter to number them (they represent different stages of a project).

The thing is, it automatically numbers like this 1.1, 1.2, 1.3 and so on, but I want them to be numbered 1, 2, 3, etc. is there a special argument I have to add on \thetcbcounter to get it that way?

Thanks

EDIT: I didn't share the code because it's not runable with all the pictures, but you can have a look. Here's my complete code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[left=0.8in,right=0.8in,top=0.5in,bottom=0.8in]{geometry}
\usepackage{array}
\usepackage[table, x11names]{xcolor}
\usepackage{array, multirow}
\usepackage{makecell, hhline}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{lc}
\newcommand\whitecell[1]{\cellcolor{white}{#1}}

\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage{listings}

\usepackage[many]{tcolorbox}

\begin{document}
\begin{center}
\begin{tcolorbox}[halign= flush center, fonttitle=\sffamily\bfseries\large, title={Lecteur DVD LG=Model GSA-H10N}, width=\linewidth/2]
\includegraphics[height=3cm]{Picture1.jpg}
\end{tcolorbox}
\end{center}
\tcbset{on line,before upper=\strut,width=10cm}

\vspace{10px} %%%%%%%%% Adding space %%%%%%%%%
\begin{minipage}{.45\linewidth}
\begin{flushleft} 
\tcbox[tcbox width=auto]{PHASES DE DEMONTAGE}
\end{flushleft} 
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
\begin{flushright}
\tcbox[tcbox width=auto limited]{ATTACHEMENTS}
\end{flushright}
\end{minipage}

\newtcolorbox[auto counter, number within=section]{mybox}[1]{fonttitle=\sffamily\bfseries\large, sidebyside, lefthand width=6.5cm,
  enhanced, remember as=first,
  title=#1,
  overlay unbroken and first ={
    \node[anchor=north east,rounded corners,draw=black!80,fill=gray!30,line width=0.5mm,text width=2.5em,align=center,minimum height=4ex] at ([xshift=-\marginparsep]frame.north west) {\thetcbcounter};
  }
}

\vspace{10px}
%%%%%%%%%%%%%%%% Phase 1
\begin{minipage}{.45\linewidth}
\begin{flushleft} 
\begin{mybox}{Démontage du boitier}
\includegraphics[height=3cm]{Picture2.JPG}% 
\hspace{10px}\includegraphics[height=3cm]{Picture3.jpg}
\tcblower
\underline{Temps:}\\\\ 4 min.\\ 30 sec.
\end{mybox}
\end{flushleft} 
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
\begin{flushright}
\begin{tcolorbox}[enhanced, width=4.5cm,
halign=center,valign=center,
square, remember as=second]
\includegraphics[height=3.5cm]{Picture4.JPG}
\end{tcolorbox}
\end{flushright}
\end{minipage}

\begin{tikzpicture}[overlay,remember picture,line width=1mm,draw=red!75!black]
\draw[->] (first.east) to (second.west);
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% Phase 2
\begin{minipage}{.45\linewidth}
\begin{flushleft} 
\begin{mybox}{Démontage de la carte mère}
\includegraphics[height=3cm]{Picture2.JPG}%
\hspace{10px}\includegraphics[height=3cm]{Picture5.JPG}
\tcblower
\underline{Temps:}\\\\ 1 min.\\ 25 sec.
\end{mybox}
\end{flushleft} 
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
\begin{flushright}
\begin{tcolorbox}[enhanced, width=4.5cm,
halign=center,valign=center,
square, remember as=third]
This is a \textbf{tcolorbox}.
\end{tcolorbox}
\end{flushright}
\end{minipage}

\begin{tikzpicture}[overlay,remember picture,line width=1mm,draw=red!75!black]
\draw[->] (first.east) to (third.west);
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%% Phase 3
\begin{mybox}{Démontage du moteur d'ouverture du lecteur}
\includegraphics[height=3cm]{Picture6.JPG}%
\hspace{10px}\includegraphics[height=3cm]{Picture7.JPG}
\tcblower
\underline{Temps:}\\\\ 45 sec.
\end{mybox}
%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% Phase 4
\begin{mybox}{Démontage de la tête de lecture}
\includegraphics[height=3cm]{Picture8.JPG}%
\hspace{10px}\includegraphics[height=3cm]{Picture9.JPG}
\tcblower
\underline{Temps:}\\\\ 1 min.
\end{mybox}
%%%%%%%%%%%%%%%%%%%%%%%%

\begin{center}
\begin{tcolorbox}[sidebyside, fonttitle=\sffamily\bfseries\large, title={Première étape de démontage}, width=15cm, halign title=flush center]
\includegraphics[height=5cm]{Picture10.JPG}
\tcblower
\underline{Temps total:} 7 min. 30 sec.\\\\
\underline{Eléments démontés:}\\
\begin{itemize}
  \item Boitier aluminium
  \item Carte mère
  \item Support CD plastique
  \item Moteur d'ouverture du lecteur
  \item Tête de lecture
\end{itemize}
\end{tcolorbox}
\end{center}

%%%%%%%%%%%%%%%% Phase 5
\begin{mybox}{Démontage de la partie métallique}
\includegraphics[height=3cm]{Picture8.JPG}%
\hspace{10px}\includegraphics[height=3cm]{Picture9.JPG}
\tcblower
\underline{Temps:}\\\\ 30 sec.
\end{mybox}
%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% Phase 6
\begin{mybox}{Démontage de }
\includegraphics[height=3cm]{Picture8.JPG}%
\hspace{10px}\includegraphics[height=3cm]{Picture9.JPG}
\tcblower
\underline{Temps:}\\\\ 1 min.
\end{mybox}
%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% Phase 7
\begin{mybox}{Démontage de }
\includegraphics[height=3cm]{Picture8.JPG}%
\hspace{10px}\includegraphics[height=3cm]{Picture9.JPG}
\tcblower
\underline{Temps:}\\\\ 1 min.
\end{mybox}
%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

This is what it looks like with the pictures enter image description here

  • We really need a complete example. I did this for the first time the other day and mine came out Case 1, Case 2, Case 3 etc. as I expected. ('Case' being text added prior to the use of the counter in the title of the box.) And the cross-references cam out as 1, 2, 3 etc. again as expected. – cfr Feb 2 '16 at 2:08
  • Normally, I'd assume the difference might be that you are using book and me article or something. But I'm not. I'm using book. Although I do not, strictly speaking, have chapters but only chapter-like things. Still, I have sections. So if it defaults to numbering-within for you, I'm not clear why it doesn't do so for me. Presumably, you are doing something in your code differently from me. But I have no idea what as you've not shared the code. – cfr Feb 2 '16 at 2:13
2

You have number within=section which numbers the boxes within the section, prepending the section number.

Delete number within=section and the boxes should be numbered with a simple counter.

  • Thanks, i didn't even see that was on, I copied a code for that cause I never used colorboxes before. Works perfectly :) – Dorian Kartalovski Feb 2 '16 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.