嗨,我正在使用 tcolorbox 制作图表。我将向您展示我的代码:
\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}
您可以从代码中看到,左侧的框是使用“\newtcolorbox”定义的。但问题是,我正在使用“记住为”选项添加箭头。问题是“记住为”是在“\netcolorbox”命令中定义的,因此我左侧的所有框都被记住为“第一个”。如何在 \begin{mybox} 命令中为左侧的每个框提供不同的记住?
第一个也起作用,但是第三个不能正常工作(当我从第一个画到第二个,然后从第一个画到第三个,依此类推)。
编辑:序言
\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}
答案1
一些说明:
- 我尽可能地忽略了警告,因为您的文档有很多,尤其是
underfull \hbox
和overfull \hbox
。第一个意味着您可能在没有内容的行中插入了换行符,例如写入\\\\
,第二个意味着您的内容超出了页边距。 - 我从您的示例中删除了大部分内容,因为一页足以展示我的解决方案。
- 选项
draft
在article
那里是因为我没有你的图像文件,删除恢复图像的选项。或者完全忽略前言。
现在来看看解决方案。由于您设置了一个名为 的新tcolorbox
名称mybox
,因此我为其分配了一个动态名称,使用remember as=a\thetcbcounter,
以便您拥有a1, a2, a3
等等。然后对于另一侧的每一侧,我b1, b2, b3
手动分配 等等。
最后,你只需要一个tikzpicture
就可以绘制所有箭头,每行都使用一个既繁琐又没必要。像这样:
\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}
我认为这很容易理解,但如果您需要帮助,请随时发表评论。它说1,2,3
因为我使用了 3 个“行”,但对于每一行,您需要将其增加一。如果您有 8 个,您可以写1,...,8
。
输出
代码
\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}