如何在非英语语言中,除了原始证明环境之外,创建具有不同排版名称的证明环境?

如何在非英语语言中,除了原始证明环境之外,创建具有不同排版名称的证明环境?

这篇文章是这个如何在非英语文档中定义具有不同于“Proof”排版名称的证明环境此外原始的证明环境,而不是代替它?

我感兴趣的语言是希伯来语,我使用的 LaTeX 语言支持是由该polyglossia包与引擎一起提供的,但我也对+xelatex组合感兴趣。babellualatex

以下是保存为的 LaTeX 文档~/test.tex,作为起点。

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{משפט}

\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setmainfont{Arial}
\begin{document}

Following is an interesting theorem.
\begin{theorem}
A house is not a home.
\end{theorem}
\begin{proof}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{proof}

\end{document}

当在终端中执行以下指令时:

> cd ~
> xelatex 测试

文件~/test.pdf已创建。在 PDF 查看器中打开时,文件显示如下。

希伯来语数学论文的基本框架。

请注意,希伯来语是一种从右到左的语言。

所需的解决方案将使我能够将以下内容添加到~\test.tex该行的正下方\end{proof}

\begin{explanation}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{explanation}

生成的 PDF 文件显示如下:

期望输出

[הסבר]请注意,可以通过向环境添加选项来临时实现所需的输出proof,因此:\begin{proof}[הסבר] ... \end{proof}。但是,我正在寻找一种解决方案,使我能够声明一个与名称不同的新环境proof

答案1

您想添加到\captions<language>

\documentclass{article}
\usepackage{polyglossia}
\usepackage{amsthm}

\setmainlanguage{hebrew}
\setotherlanguage{english}
\setmainfont{Arial}

\newtheorem{theorem}{\theoremname}
\newenvironment{explanation}
  {\let\proofname\explanationname\begin{proof}}%
  {\end{proof}}

\newcommand{\theoremname}{Theorem}% default
\newcommand{\explanationname}{Explanation}% default
\appto{\captionshebrew}{%
  \renewcommand\theoremname{משפט}%
  \renewcommand\explanationname{הסבר}%
}
\appto{\captionsenglish}{%
  \renewcommand\theoremname{Theorem}%
  \renewcommand\explanationname{Explanation}%
}

\begin{document}

Following is an interesting theorem.

\begin{theorem}
A house is not a home.
\end{theorem}
\begin{proof}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}

\selectlanguage{english}

\begin{theorem}
A house is not a home.
\end{theorem}
\begin{proof}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}

\end{document}

在此处输入图片描述

稍微不同的方法,也许更简单。

\documentclass{article}
\usepackage{polyglossia}
\usepackage{amsthm}

\setmainlanguage{hebrew}
\setotherlanguage{english}
\setmainfont{Arial}

\newcommand{\theoremname}{Theorem}% default
\newcommand{\explanationname}{Explanation}% default
\appto{\captionshebrew}{%
  \renewcommand\theoremname{משפט}%
  \renewcommand\explanationname{הסבר}%
}
\appto{\captionsenglish}{%
  \renewcommand\theoremname{Theorem}%
  \renewcommand\explanationname{Explanation}%
}

\newtheorem{theorem}{\theoremname}

\NewDocumentEnvironment{explanation}{o}
 {\IfNoValueTF{#1}{\proof[\explanationname]}{\proof[#1]}}
 {\endproof}

\begin{document}

Following is an interesting theorem.

\begin{theorem}
A house is not a home.
\end{theorem}
\begin{proof}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}
\begin{explanation}[הסבר נוסף]
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}

\selectlanguage{english}

\begin{theorem}
A house is not a home.
\end{theorem}
\begin{proof}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}
\begin{explanation}[Further explanation]
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}

\end{document}

在此处输入图片描述

答案2

对于babelluatex(略有变化)xetex

\documentclass{article}

\usepackage{amsthm}
\newtheorem{theorem}{\theoremname}

\newenvironment{explanation}%
   {\renewcommand\proofname{\explanationname}%
    \begin{proof}}
   {\end{proof}}

% For LuaTeX. For XeTeX use bidi=bidi
\usepackage[bidi=basic, english, hebrew, provide=*]{babel}
\babelfont{rm}{FreeSans}

\setlocalecaption{hebrew}{theorem}{משפט}
\setlocalecaption{hebrew}{explanation}{הסבר}
\setlocalecaption{english}{theorem}{Theorem}
\setlocalecaption{english}{explanation}{Explanation}

\begin{document}

Following is an interesting theorem.
\begin{theorem}
  A house is not a home.
\end{theorem}
\begin{proof}
  A chair is still a chair, even when there's no one sitting there.
  But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
  A chair is still a chair, even when there's no one sitting there.
  But a chair is not a house, and a house is not a home.
\end{explanation}

\selectlanguage{english}

Following is an interesting theorem.
\begin{theorem}
  A house is not a home.
\end{theorem}
\begin{proof}
  A chair is still a chair, even when there's no one sitting there.
  But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
  A chair is still a chair, even when there's no one sitting there.
  But a chair is not a house, and a house is not a home.
\end{explanation}

\end{document}

在此处输入图片描述

答案3

以下解决方案基于Mico 对我的另一个问题的回答。然而,这种解决方案对于双语文档中人们希望explanation环境对语言敏感,就像环境proof对语言敏感一样。

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{משפט}

% The following is based on Mico's answer here:
% https://tex.stackexchange.com/a/664972/21685
% BEGIN
\newcommand\explanationname{Explanation} % could be made language-dependent
\newenvironment{explanation}%
   {\begingroup
    \renewcommand\proofname\explanationname%
    \begin{proof}[הסבר]}%
   {\end{proof}%
    \endgroup}
% END

\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setmainfont{Arial}
\begin{document}

Following is an interesting theorem.

\begin{theorem}
A house is not a home.
\end{theorem}
\begin{proof}
   A chair is still a chair, even when there's no one sitting there.
   But a chair is not a house, and a house is not a home.
\end{proof}
\begin{explanation}
   When there's no one there to hold you tight,
   and no one there you can kiss goodnight,
   a house is not a home.
\end{explanation}

\end{document}

相关内容