TColorBox 和 Tikz,箭头不在图表上

TColorBox 和 Tikz,箭头不在图表上

下面我包含了一个 mwe。如您所见,在最后一张图中,最后三个框的错误呈现在下一页上。我该如何解决这个问题?我使用使用此命令的 TexShop 进行编译pdftex --file-line-error --synctex=1。是的,我已经编译了两次以上。

\documentclass[11pt, letterpaper, oneside]{memoir}

\usepackage{libertine}
\usepackage{libertinust1math}
\usepackage[T1]{fontenc}

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{enumitem, amssymb}
\usepackage{textcomp}
\usepackage[tracking = true, letterspace = 125]{microtype}
\usepackage{soul}
\usepackage{mfirstuc}
\usepackage{scalerel}
\usepackage[skins, raster]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{decorations,decorations.markings}
\usepackage{etoolbox}
\usetikzlibrary{optics}
\usepackage{draftwatermark}
\usepackage[pass]{geometry}
\usepackage[hyphens]{url}
\usepackage{hyperxmp}
\usepackage{hyperref}
\usepackage{xfrac}
\usepackage{multicol}

\usepackage[english]{babel}
\usepackage{blindtext}

% force LaTeX to write the author, title, and copyright into the PDF
\makeatletter
  \AtEndDocument{\hyxmp@find@metadata\hyxmp@embed@packet}
\makeatother
\hypersetup{
    colorlinks=true,
    linktoc=all,
    urlcolor=blue,
    linkcolor=part,
    draft=false,
    pdfauthor={some authoer},
    pdftitle={some org},
    pdfcopyright={Copyright \copyright~2019 by author. Some rights reserved.},
    pdfpagelabels=true,
    implicit=false
}

\chapterstyle{ell}

\setlength{\emergencystretch}{6pt}
\setlrmarginsandblock{1in}{1in}{*}
\checkandfixthelayout
\linespread{1.3}

%%%%%%%%%%%%%%%%%%%%%%%%%%
%   The Document
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\title{A Title}
\author{An Author}
\date{}
\maketitle

\frontmatter

\blindtext

\mainmatter

\Blindtext
\tcbset{enhanced, nobeforeafter, sidebyside align=top,box align=center, width=1.6in}

\begin{center}
\begin{tcolorbox}[remember as=one]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=two]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=three]
Many more somethings happen and the world nearly dies
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=four]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=five]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=six]
a result
\end{tcolorbox}
\end{center}

\begin{tikzpicture}[overlay,remember picture,line width=0.5mm]
\draw[->] (one.east) to (two.west);
\draw[->] (three.east) to (four.west);
\draw[->] (five.east) to (six.west);
\end{tikzpicture}

\blindtext
\begin{center}
\begin{tcolorbox}[remember as=1]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=2]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=3]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=4]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=5]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=6]
a result
\end{tcolorbox}
\end{center}

\begin{tikzpicture}[overlay,remember picture,line width=0.5mm]
\draw[->] (1.east) to (2.west);
\draw[->] (3.east) to (4.west);
\draw[->] (5.east) to (6.west);
\end{tikzpicture}

\backmatter

\blindtext

\end{document}

箭头不在图表上

答案1

只需将 tikzpicture 放在相同的center环境中即可强制它位于同一页面...LaTeX 决定将颜色框放在下一页但改变了主意并在之前的第二次考虑后强制这样做...tikz 图片在环境之外并且没有遵循 LaTeX 的第二个想法因为它是在第二次内部编译后打印的(需要比真正的 tikzpicture 多一个作为覆盖)...希望有所帮助。

\documentclass[11pt, letterpaper, oneside]{memoir}

\usepackage{libertine}
\usepackage{libertinust1math}
\usepackage[T1]{fontenc}

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{enumitem, amssymb}
\usepackage{textcomp}
\usepackage[tracking = true, letterspace = 125]{microtype}
\usepackage{soul}
\usepackage{mfirstuc}
\usepackage{scalerel}
\usepackage[skins, raster]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{decorations,decorations.markings}
\usepackage{etoolbox}
\usetikzlibrary{optics}
\usepackage{draftwatermark}
\usepackage[pass]{geometry}
\usepackage[hyphens]{url}
\usepackage{hyperxmp}
\usepackage{hyperref}
\usepackage{xfrac}
\usepackage{multicol}

\usepackage[english]{babel}
\usepackage{blindtext}

% force LaTeX to write the author, title, and copyright into the PDF
\makeatletter
  \AtEndDocument{\hyxmp@find@metadata\hyxmp@embed@packet}
\makeatother
\hypersetup{
    colorlinks=true,
    linktoc=all,
    urlcolor=blue,
    linkcolor=part,
    draft=false,
    pdfauthor={some authoer},
    pdftitle={some org},
    pdfcopyright={Copyright \copyright~2019 by author. Some rights reserved.},
    pdfpagelabels=true,
    implicit=false
}

\chapterstyle{ell}

\setlength{\emergencystretch}{6pt}
\setlrmarginsandblock{1in}{1in}{*}
\checkandfixthelayout
\linespread{1.3}

%%%%%%%%%%%%%%%%%%%%%%%%%%
%   The Document
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\title{A Title}
\author{An Author}
\date{}
\maketitle

\frontmatter

\blindtext

\mainmatter

\Blindtext
\tcbset{enhanced, nobeforeafter, sidebyside align=top,box align=center, width=1.6in}

\begin{center}
\begin{tcolorbox}[remember as=one]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=two]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=three]
Many more somethings happen and the world nearly dies
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=four]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=five]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=six]
a result
\end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture,line width=0.5mm]
\draw[->] (one.east) to (two.west);
\draw[->] (three.east) to (four.west);
\draw[->] (five.east) to (six.west);
\end{tikzpicture}
\end{center}

\blindtext
\begin{center}
\begin{tcolorbox}[remember as=1]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=2]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=3]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=4]
a result
\end{tcolorbox}
\end{center}

\begin{center}
\begin{tcolorbox}[remember as=5]
Something happens
\end{tcolorbox}
\qquad
\begin{tcolorbox}[remember as=6]
a result
\end{tcolorbox}
\begin{tikzpicture}[overlay,remember picture,line width=0.5mm]
\draw[->] (1.east) to (2.west);
\draw[->] (3.east) to (4.west);
\draw[->] (5.east) to (6.west);
\end{tikzpicture}
\end{center}
\clearpage
\backmatter

\blindtext

\end{document}

相关内容