我正在使用该media9
软件包将声音文件嵌入到我的文档中。这在普通文本中运行得很好,但是当尝试在表格环境中运行相同的命令时,LaTeX 显然会陷入某种循环。事实上,编译似乎永远持续下去;然而,它确实给了我错误消息(尽管仍在拼命尝试编译):
! 不正确的字母常量。\unskip l.26 \listen{test.mp3}{hello}
我使用的代码是:
\documentclass{memoir}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,geometry,graphicx,amstext,tipa}
\usepackage{media9}
\newcommand*\listen[2]{ % listen to the file named #1, but write out #2
\includemedia[
addresource=#1,
transparent,
flashvars={
source=#1
&autoPlay=true
&hideBar=true
},
]{#2}{APlayer.swf}
}
\begin{document}
\listen{test.mp3}{hello} %this works fine
\begin{tabular}{ccc}
\listen{test.mp3}{hello} %this causes a painful death
& what
& is\\
the
& problem
& here
\end{tabular}
\end{document}
答案1
您的定义(经过几次扩展)处于&
顶层,因此弄乱了表格单元格,请添加{}
以隐藏它们:
\newcommand*\listen[2]{{%% listen to the file named #1, but write out #2
\includemedia[
addresource=#1,
transparent,
flashvars={
source=#1
&autoPlay=true
&hideBar=true
},
]{#2}{APlayer.swf}%
}}
请注意,在定义的开始和结束处还有虚假的空格标记,我也将其删除了。