1

Hi I'm making a chart using tcolorbox. I'll show you my code:

\begin{center}
\begin{tcolorbox}[halign= flush center, halign title= flush center, fonttitle=\sffamily\bfseries\large, title={Lecteur DVD LG=Modèle GSA-H10N}, width=9cm]
\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]{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=0.8mm,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_1.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]
\includegraphics[height=3.5cm]{Picture2_2.jpg}
\end{tcolorbox}
\end{flushright}
\end{minipage}

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

%%%%%%%%%%%%%%%%% Phase 3
\begin{minipage}{.45\linewidth}
\begin{flushleft} 
\begin{mybox}{Démontage du boitier}
\includegraphics[height=3cm]{Picture6.JPG}% 
\hspace{10px}\includegraphics[height=3cm]{Picture7.JPG}
\tcblower
\underline{Temps:}\\\\ 45 sec.
\end{mybox}
\end{flushleft} 
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
\begin{flushright}
\begin{tcolorbox}[enhanced, overlay, width=4.5cm,
halign=center,valign=center,
square, remember as=fourth]
\includegraphics[height=3.5cm]{Picture2_3.jpg}
\end{tcolorbox}
\end{flushright}
\end{minipage}

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

%%%%%%%%%%%%%%%% 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,lefthand width=6.5cm, fonttitle=\sffamily\bfseries\large, title={Première étape de démontage}, width=14cm, 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}[leftmargin=*]
  \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}

Which gives me something like this: enter image description here

You can see from the code that the boxes on the left are defined using '\newtcolorbox'. But the thing is I am adding arrows, using the remember as option. Problem is 'remember as' is defined in the '\netcolorbox' command, so all my boxes on the left are remembered as 'first'. How can I give a different remember as to each box on the left in the \begin{mybox} command?

It worked for the first too, but the Third one is not working properly (when I draw from first to second, then first to third, and so on).

EDIT: Preamble

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{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,french]{babel}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage{listings}
\usepackage[many]{tcolorbox}
\usepackage{url}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{parskip}
\usepackage[numbers]{natbib}
\usepackage[shortlabels]{enumitem}
\setlist[itemize]{label=\textbullet}

\setlength{\parindent}{0pt}
\newcommand{\forceindent}{\leavevmode{\parindent=1em\indent}}

\usetikzlibrary{arrows,shapes.geometric,positioning}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{natbib}
\usepackage{wrapfig}

\usepackage{titlesec}
\titleformat*{\section}{\huge\bfseries}
\titleformat*{\subsection}{\Large\bfseries}

\usepackage{hyperref}
\hypersetup{urlcolor=blue, colorlinks=true, linkcolor=black, citecolor=blue}
3
  • Please add your preamble. Your code shows a lot of errors from unknown options and commands.
    – Alenanno
    Commented Feb 5, 2016 at 17:07
  • Also, your code does not give your image as a result, there's a lot of underfull and overfull hboxes.
    – Alenanno
    Commented Feb 5, 2016 at 17:14
  • Well there's three pages of boxes, I just screenshot the beginning cause it's essentially the same. I'll add the preamble with all the packages i'm using Commented Feb 5, 2016 at 17:22

1 Answer 1

3

Some notes:

  • I ignored the warnings when possible because your document has a lot, especially underfull \hbox and overfull \hbox. The first one means that you have maybe inserted a line break where the line had no content, such as writing \\\\, the second one means that your content exceeds the page margins.
  • I removed most of the content from your example because one page was enough to show my solution.
  • The option draft in article is there because I don't have your image files, remove the option to restore the images. Or ignore the preamble altogether.

And now the solution. Since you set a new tcolorbox called mybox, I assigned a dynamic name to it, using remember as=a\thetcbcounter, So that you have a1, a2, a3 and so on. Then for each of the other side, I assigned b1, b2, b3 and so on, manually.

Finally, you only need one tikzpicture to draw all the arrows, using one for each row is tedious and unnecessary. Like this:

\begin{tikzpicture}[overlay,remember picture,->, line width=0.8mm,draw=red!75!black]
    \foreach \x in {1,2,3}{%
        \draw (a\x.east) -- (b\x.west);
    }    
\end{tikzpicture}

I think it's fairly understandable, but feel free to comment if you need assistance. It says 1,2,3 because I used 3 "rows", but for each row, you need to increase it by one. If you have, say, 8, you can write 1,...,8.

Output

enter image description here

Code

\documentclass[draft]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}
\usepackage[most]{tcolorbox}

\begin{document}
\begin{center}
\begin{tcolorbox}[halign= flush center, halign title= flush center, fonttitle=\sffamily\bfseries\large, title={Lecteur DVD LG=Modèle GSA-H10N}, width=9cm]
\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]{mybox}[1]{fonttitle=\sffamily\bfseries\large, sidebyside, lefthand width=6.5cm,
  enhanced, remember as=a\thetcbcounter,
  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=b1]
\includegraphics[height=3.5cm]{Picture4.JPG}
\end{tcolorbox}
\end{flushright}
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% Phase 2
\begin{minipage}{.45\linewidth}
\begin{flushleft} 
\begin{mybox}{Démontage de la carte mère}
\includegraphics[height=3cm]{Picture2_1.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=b2]
\includegraphics[height=3.5cm]{Picture2_2.jpg}
\end{tcolorbox}
\end{flushright}
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%% Phase 3
\begin{minipage}{.45\linewidth}
\begin{flushleft} 
\begin{mybox}{Démontage du boitier}
\includegraphics[height=3cm]{Picture6.JPG}% 
\hspace{10px}\includegraphics[height=3cm]{Picture7.JPG}
\tcblower
\underline{Temps:}\\\\ 45 sec.
\end{mybox}
\end{flushleft} 
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
\begin{flushright}
\begin{tcolorbox}[enhanced, overlay, width=4.5cm,
halign=center,valign=center,
square, remember as=b3]
\includegraphics[height=3.5cm]{Picture2_3.jpg}
\end{tcolorbox}
\end{flushright}
\end{minipage}

\begin{tikzpicture}[overlay,remember picture,->, line width=0.8mm,draw=red!75!black]
    \foreach \x in {1,2,3}{%
        \draw (a\x.east) -- (b\x.west);
    }    
\end{tikzpicture}
\end{document}
4
  • Yep it's working, for the underfull, I used \\\\ for the Time, cause I didn't how it was too cramped. For the overfull yeah I think it's the number that's outside the margin, but I will try to move the left boxes in the margin area. Thanks Commented Feb 5, 2016 at 17:37
  • @DorianKartalovski The black vertical lines you see in my output are the elements exceeding the margin, visible thanks to the draft option.
    – Alenanno
    Commented Feb 5, 2016 at 17:39
  • mm ok, not sure why then, but how can I solve this? Commented Feb 5, 2016 at 17:40
  • @DorianKartalovski Make them smaller :P for example, \includegraphics could be made smaller.
    – Alenanno
    Commented Feb 5, 2016 at 17:57

You must log in to answer this question.

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