我想\verb
在里面使用\IfLanguageName
。但我收到错误消息\verb ended by end of line. ...ame{english}{... \verb| echo Hello | ...}{}
。我想同时只显示一种语言。
\documentclass{article}
\usepackage{iflang}
\begin{document}
\setlanguage{english}
\IfLanguageName{swedish}{... \verb| echo Hello | ...}{}
\IfLanguageName{english}{... \verb| echo Hello | ...}{}
\end{document}
答案1
你可以定义一个环境。通过定义与我们所得到的可管理语法\Stop
相同。\fi
\documentclass{article}
\usepackage[swedish,english]{babel}
\usepackage{iflang}
\makeatletter
\newenvironment{languageswitch}
{\expandafter\let\csname Start@\languagename\endcsname\@empty}
{\ignorespacesafterend}
\newcommand{\Start}[1]{%
\@ifundefined{Start@#1}{\iffalse}{\iftrue\ignorespaces}%
}
\let\Stop\fi
\makeatother
\begin{document}
\section{English}
\begin{languageswitch}
\Start{swedish}
... \verb| echo svenska | ...
\Stop
\Start{english}
... \verb| echo English | ...
\Stop
\end{languageswitch}
\section{Swedish}
\selectlanguage{swedish}
\begin{languageswitch}
\Start{swedish}
... \verb| echo svenska | ...
\Stop
\Start{english}
... \verb| echo English | ...
\Stop
\end{languageswitch}
\end{document}