我不知道为什么我的代码无法编译,这是一个很长的代码,我不知道问题出在之前\begin{document}
还是之后。感谢您的阅读,以下是代码:
我认为主要的错误是: \language@active@arg~ 的参数有一个多余的}。
\documentclass[a4paper, 1pt]{book}
\usepackage{lmodern}
% matemáticas:
\usepackage{amsmath, amssymb}
% idioma:
\usepackage[utf8]{inputenc}
\usepackage[spanish, es-tabla]{babel} % 'cuadro' es el título del caption de table por defecto siguiendo indicaciones de RAE; es-tabla lo cambia a 'tabla'
% gestión de párrafos (hace innecesario indicar el salto de línea con doble barra y elimina el indent de todos los párrafos):
\usepackage{parskip}
% enlaces a URLs:
\usepackage{hyperref}
% gráficos:
\usepackage{graphicx, wrapfig, subcaption}
% tablas:
\usepackage{array, multirow}
\newcommand{\dl}{\left(}
\newcommand{\dr}{\right)}
\newcommand{\dsin}[1]{\sin{\left(#1\right)}}
\newcommand{\dtan}[1]{\tan{\left(#1\right)}}
\newcommand{\dcos}[1]{\cos{\left(#1\right)}}
\newcommand{\dsec}[1]{\sec{\left(#1\right)}}
\newcommand{\dcsc}[1]{\csc{\left(#1\right)}}
\newcommand{\dcot}[1]{\cot{\left(#1\right)}}
\newcommand{\darcsin}[1]{\arcsin{\left(#1\right)}}
\newcommand{\darccos}[1]{\arccos{\left(#1\right)}}
\newcommand{\darctan}[1]{\arctan{\left(#1\right)}}
\newcommand{\dsinh}[1]{\sinh{\left(#1\right)}}
\newcommand{\dcosh}[1]{\cosh{\left(#1\right)}}
\newcommand{\dtanh}[1]{\tanh{\left(#1\right)}}
\newcommand{\dln}[1]{\ln{\left(#1\right)}}
\newcommand{\dsum}[2]{\displaystyle\sum_{#1}^{#2}}
\newcommand{\dlim}[2]{\lim_{#1\rightarrow#2}}
\newcommand{\dint}[2]{\displaystyle\int_{#1}^{#2}}
\newcommand{\doint}[2]{\displaystyle\oint_{#1}^{#2}}
\NewDocumentCommand{\umathnote}{ mm }
{
\overset % ❶
{% The annotation goes above
\textcolor{black!20!white}{\hbox to 0pt{\hss % ❷
$ % return to math mode
\begin{array}{c} % ❸
\displaystyle #2\\ % ❹
\Big\downarrow % ❺
\end{array}
$
\hss}
}
}
{#1} %
}
\NewDocumentCommand{\dmathnote}{ mm }
{
\underset % ❶
{% The annotation goes above
\textcolor{black!20!white}{\hbox to 0pt{\hss % ❷
$ % return to math mode
\begin{array}{c} % ❸
\Big\uparrow\\ % ❹
\displaystyle #2 % ❺
\end{array}
$
\hss}
}
}
{#1} %
}
\renewcommand{\baselinestretch}{0.5}
\usepackage{titlesec}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{-2.5ex\@plus -1ex \@minus -.25ex}%
{1.25ex \@plus .25ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
\setcounter{secnumdepth}{4} % how many sectioning levels to assign numbers to
\setcounter{tocdepth}{4} % how many sectioning levels to show in ToC
\usepackage[all]{xy}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{tikz}
\usetikzlibrary{calc, arrows}
\usepackage[makeroom]{cancel}
\newenvironment{grand}
{\begin{center}\large}
{\end{center}}
\usepackage[framemethod=TikZ]{mdframed}
\newcounter{dem}[chapter]\setcounter{dem}{0}
\renewcommand{\thedem}{\Roman{dem}}
\newenvironment{dem}[2][]{%
\refstepcounter{dem}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=white]
{\strut Tema~\thedem};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=white]
{\begin{minipage}{0.99\linewidth}#1\end{minipage}};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=black,%
linewidth=0.5pt,topline=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}
\usepackage{nccmath}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\newtcolorbox[auto counter,
number within=chapter,
list inside=ej
]{ej}[1][]{%
enhanced, breakable,
title={{\begin{minipage}{\linewidth}\textbf{Ejercicio}~\thetcbcounter.~\textit{#1}\end{minipage}}},
halign title=left,
sharp corners,
colback=white,
coltitle=black,
colbacktitle=white,
boxrule=0pt,frame hidden,
underlay unbroken and first={%
\ifnumequal{\tcbsegmentstate}{0}{
\draw[black,double] (interior.north west)--(interior.south west);
}{\ifnumequal{\tcbsegmentstate}{1}{
\draw[black,double] (interior.north west)--(segmentation.west);
\begin{tcbclipinterior}
\draw[help lines, step=3.8mm, black!20!white](segmentation.south west) grid (frame.south east);
\end{tcbclipinterior}
}{\ifnumequal{\tcbsegmentstate}{2}{
\begin{tcbclipinterior}
\draw[help lines, step=3.8mm, black!20!white](interior.north west) grid (interior.south east);
\end{tcbclipinterior}
}}}
},
underlay middle and last={%
\ifnumequal{\tcbsegmentstate}{0}{
\draw[black,double] (interior.north west)--(interior.south west);
}{\ifnumequal{\tcbsegmentstate}{1}{
\draw[black,double] (interior.north west)--(segmentation.west);
\begin{tcbclipinterior}
\draw[help lines, step=3.8mm, black!20!white](segmentation.south west) grid (frame.south east);
\end{tcbclipinterior}
}{\ifnumequal{\tcbsegmentstate}{2}{
\begin{tcbclipinterior}
\draw[help lines, step=3.8mm, black!20!white](interior.north west) grid (interior.south east);
\end{tcbclipinterior}
}}}
},
boxed title style={%
colframe=white,
boxrule=0pt,
colback=white,
left=0pt,
right=0pt},
attach boxed title to top left={xshift={-5pt}},
lower separated=false,
before lower = {\tcbsubtitle[colback=white, opacityback=0, colframe=black, opacityframe=0, boxrule=1pt, height=1cm, width=2.55cm, valign=center]{\textbf{Solution:}}}
}
\newtcolorbox[auto counter,
number within=chapter,
list inside=defi
]{defi}[1][]{%
enhanced,
title={{\begin{minipage}{0.99\linewidth}\textit{#1}\end{minipage}}},
,
halign title=left,
sharp corners,
colback=white,
coltitle=black,
colbacktitle=white,
boxrule=0pt,frame hidden,
overlay unbroken={%
\draw[black,double] (interior.north west)--(interior.south west);%
},
boxed title style={%
colframe=white,
boxrule=0pt,
colback=white,
left=0pt,
right=0pt},
attach boxed title to top left={xshift={-5pt}},
}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage[bottom=0.5cm,top=0.5cm,right=0.5cm,left=0.5cm,binding=0.5cm]{geometry}
\begin{document}
\begin{dem}[Estructura cristalina]{}
\underset{\text{Átomos en volumen}}{\footnotesize\fbox{$N_{a_V}=\dfrac{N_A\rho V}{M_{mol}}$}}
\underset{\text{~}}{\footnotesize\fbox{$S=4\pi r^2$}}
\underset{\text{~}}{\footnotesize\fbox{$V=\dfrac{4}{3}\pi r^3$}}
\underset{\text{Densidad celda}}{\footnotesize\fbox{$\rho=\dfrac{N\cdot M_A}{V_c\cdot N_A}$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\end{dem}
\begin{dem}[Red recíproca{}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\end{dem}
\begin{dem}[Estructura cristalina y difracción de rayos X]{}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\end{dem}
\begin{dem}[Propiedades mecánicas y térmicas]{}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\underset{\text{~}}{\footnotesize\fbox{$~$}}
\end{dem}
\end{document}
答案1
geometry
测试文件的更合理版本(修复对未定义选项的调用后binding
)将是
\documentclass{book}
\usepackage{amsmath}
\begin{document}
\underset{\text{Átomos en volumen}}{\footnotesize\fbox{$N_{a_V}=\dfrac{N_A\rho V}{M_{mol}}$}}
\end{document}
这使
LaTeX Font Warning: Command \footnotesize invalid in math mode on input line 6.
! Missing $ inserted.
<inserted text>
$
l.6 ...fbox{$N_{a_V}=\dfrac{N_A\rho V}{M_{mol}}$}}
?
因为\footnotsize
在数学中不允许,而\underset
在数学中必须是,所以运行起来没有错误
\documentclass{book}
\usepackage{amsmath}
\begin{document}
$\underset{\text{Átomos en volumen}}{\fbox{$N_{a_V}=\dfrac{N_A\rho V}{M_{\mathrm{mol}}}$}}$
\end{document}
如果你修复了该错误的多个实例,那么\underset
在数学上也是如此,你的测试文件将解析为
\documentclass{book}
\usepackage[spanish, es-tabla]{babel}
\usepackage{amsmath}
\begin{document}
$\underset{\text{~}}{\fbox{$~$}}$
\end{document}
产生
! Argument of \language@active@arg~ has an extra }.
<inserted text>
\par
l.7 $\underset{\text{~}}{\fbox{$~$}}
$
?
西班牙语 babel 的~
简写形式也是~n
ñ
您可以禁用速记,但这~
没有任何用处,因为不能换行,所以您可以使用普通空格。
\documentclass{book}
\usepackage[spanish, es-tabla]{babel}
\usepackage{amsmath}
\begin{document}
$\underset{\text{ }}{\fbox{ }}$
\end{document}
不产生错误(尽管这是一个非常奇怪的构造)