我正在使用 TexLive(Ubuntu)编写带有 TeX 的文档,我已经安装了,它可以与和一起struktex
正常运行,但是当我尝试编写语句时会引发错误。if
assing
case
这是代码:
\documentclass[a4paper,11pt,spanish]{book}
\usepackage{babel}
\usepackage[latin1]{inputenc}
\usepackage[margin=0.75in]{geometry}
\usepackage{courier}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{struktex}
\begin{document}
\begin{struktogramm}(95,30)
\case[10]{4}{3}{Signum(x)}{-1}
\assign{\(a \gets - \frac{1}{x}\)}
\switch{0}
\assign{Output: Division by 0}
\switch{1}
\assign{\(a \gets \frac{1}{x}\)}
\caseend
\end{struktogramm}
\end{document}
错误如下:
./TestCase.tex:23:Argument of \language@active@arg~ has an extra } \switch{0} ./TestCase.tex:23:Paragraph ended before \language@active@arg~ was complete \switch{0} ./TestCase.tex:25:Argument of \language@active@arg~ has an extra } \switch{1} ./TestCase.tex:25:Paragraph ended before \language@active@arg~ was complete \switch{1}
答案1
西班牙语 babel 手册中提到了这个问题
www.tex-tipografia.com/archive/spanish.pdf
应该适用于\renewcommand\shorthandsspanish{}
\documentclass[a4paper,11pt,spanish]{book}
\usepackage{babel}
\renewcommand\shorthandsspanish{}
\usepackage[latin1]{inputenc}
\usepackage[margin=0.75in]{geometry}
\usepackage{courier}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{struktex}
\begin{document}
\begin{struktogramm}(95,30)
\case[10]{4}{3}{Signum(x)}{-1}
\assign{\(a \gets - \frac{1}{x}\)}
\switch{0}
\assign{Output: Division by 0}
\switch{1}
\assign{\(a \gets \frac{1}{x}\)}
\caseend
\end{struktogramm}
\end{document}
答案2
es-notilde
您仍然可以通过将选项传递给来保留大多数简写babel
:
\documentclass[a4paper,11pt,spanish]{book}
\usepackage[es-notilde]{babel}
\usepackage[latin1]{inputenc}
\usepackage[margin=0.75in]{geometry}
\usepackage{courier}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{struktex}
\begin{document}
\begin{struktogramm}(95,30)
\case[10]{4}{3}{Signum(x)}{-1}
\assign{\(a \gets - \frac{1}{x}\)}
\switch{0}
\assign{Output: Division by 0}
\switch{1}
\assign{\(a \gets \frac{1}{x}\)}
\caseend
\end{struktogramm}
\end{document}
无论如何,使用波浪号作为西班牙语的简写已被弃用。
说\renewcommand\shorthandsspanish{}
将不允许全部简写。通过将es-noshorthands
选项传递给可以更方便地获得此信息babel
。