我遇到了一些问题\ref
。我猜这是由我自己为定义框和类似物创建的样式引起的(来自使用 Boiboites 软件包 TikZ 打破页面)。
\documentclass[11pt]{book}
%I HOPE THERE'S NO MISSING PACKAGES OR CONFLICTING COMBINATIONS.
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish, activeacute]{babel}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{hyperref}
\usepackage[usenames, dvipsnames]{xcolor}
\usepackage{ntheorem} %Para crear estos nuevos comandos.
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}
\newcounter{ndefi}[chapter] %Counter created for definitions.
%Creating little box for the definition.
\newcommand{\defitit}{
\node[fill=green!20,
rounded corners,
draw=black,
text=black,
line width=1pt,
inner sep=4pt,
anchor=west,
xshift=12pt]
at (frame.north west){\bfseries Definición \stepcounter{ndefi} \thechapter.\thendefi -.};
}
%Creating the big box for the definition.
\newtcolorbox{defi}{
enhanced,
overlay unbroken and first={\defitit},
colframe=green,
boxrule=1pt,
arc=3mm,
breakable,
top=15pt,
before=\vskip18pt,
}
\begin{document}
\chapter{El capítulo fantasma de las cosas de prueba.}
\section{Donde las cajas de definición y demás se prueban.}
\begin{defi}[Prueba de título] \label{probando1}
Probando, probando... 1, 2, 3...
\end{defi}
\begin{defi}\label{probando2}
Probando, probando... 1, 2, 3...
\end{defi}
\begin{defi}
Probando, probando... 1, 2, 3...
\end{defi} \label{probando5}
\label{probando6}\begin{defi}
Probando, probando... 1, 2, 3...
\end{defi}
Trying the references of definitions \ref{probando1}, \ref{probando2}, \ref{probando5} and \ref{probando6}.
\end{document}
无论我把标签贴在哪里,参考都无法正常工作,只能显示部分并引用它。我猜问题出在我为制作这些盒子而创建的环境上,但我不知道。或者也许问题是我必须使用不同的东西\label
或\ref
...
答案1
标签必须作为 的一个选项给出tcolorbox
。
这也是针对标题的一个建议。
\documentclass[11pt]{book}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage[usenames, dvipsnames]{xcolor}
\usepackage{hyperref}
%\usepackage{ntheorem} %Para crear estos nuevos comandos.
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}
\newcounter{ndefi}[chapter] %Counter created for definitions.
% delay the redefinition because otherwise tcolorbox would override it
\AtBeginDocument{\renewcommand{\thendefi}{\thechapter.\arabic{ndefi}}}
%Creating little box for the definition.
\newcommand{\defitit}[1]{%
\node[fill=green!20,
rounded corners,
draw=black,
text=black,
line width=1pt,
inner sep=4pt,
anchor=west,
xshift=12pt]
at (frame.north west){\bfseries Definición \thendefi.#1\unskip};
}
\providecommand{\thisdefititle}{}
%Creating the big box for the definition.
\newtcolorbox[use counter=ndefi]{defi}[1][]{
dtitle/.store in=\thisdefititle,
enhanced,
overlay unbroken and first={\defitit{ \thisdefititle}},
colframe=green,
boxrule=1pt,
arc=3mm,
breakable,
top=15pt,
before=\vspace{18pt},
#1,
}
\begin{document}
\chapter{El capítulo fantasma de las cosas de prueba.}
\section{Donde las cajas de definición y demás se prueban.}
\begin{defi}[dtitle=Prueba de título,label=probando1]
Probando, probando... 1, 2, 3...
\end{defi}
\begin{defi}[label=probando2]
Probando, probando... 1, 2, 3...
\end{defi}
\begin{defi}[label=probando3]
Probando, probando... 1, 2, 3...
\end{defi}
\begin{defi}[label=probando4]
Probando, probando... 1, 2, 3...
\end{defi}
Trying the references of definitions
\ref{probando1}, \ref{probando2}, \ref{probando3} and \ref{probando4}.
\end{document}
我会避免使用activeacute
如今已基本过时的选项,因为您可以直接输入重音字符。