3

Picking up on this comment, how can I define a proof environment with a different typeset name than "Proof" (say, "Explanation") in such a way that the new environment coexists rather than supplants the original proof environment?

I currently use the amsthm package to generate proof environments, but if it helps, I don't mind loading another package.

Mico
  • 506,678
Evan Aad
  • 11,066
  • Give \renewcommand\proofname{Explanation} a try. – Mico Nov 13 '22 at 06:50
  • 1
    @Mico Isn't this essentially the same solution as here? – Evan Aad Nov 13 '22 at 06:51
  • 1
    Ah, I had missed the fact that you want a solution that coexists with the existing proof environment. Let me post a longer answer. – Mico Nov 13 '22 at 06:53
  • @Mico Thank you. If you don't mind, could you please also indicate in your answer how it can be done in a bilingual document that uses the polyglossia package? – Evan Aad Nov 13 '22 at 06:58
  • Which are the two languages? – Mico Nov 13 '22 at 07:01
  • 1
    @Mico Does it matter? Won't the same principle apply to all languages? But if the specific second language is critical, then Hebrew; the first one being English. – Evan Aad Nov 13 '22 at 07:02
  • Thanks. It matters for how polyglossia's machinery needs to be told to swing into action. – Mico Nov 13 '22 at 07:04
  • @Mico Would you rather I open another question for the polyglossia variation? – Evan Aad Nov 13 '22 at 07:37
  • 1
    Yes please. I've been struggling for the past half hour with augmenting my answer to handle multiple languages, using either babel or polyglossia, but so far without luck. I've generalized the answer to use a macro called \explanationname instead of hard-coding the name of the environment. Maybe that'll be useful in making language-specific adaptations. – Mico Nov 13 '22 at 07:45
  • 1

1 Answers1

3

You could define a new LaTeX environment called, say, explanation. Entering a LaTeX environment automatically starts a new TeX group. This environment first redefines the macro \proofname and then opens a proof environment. At the end of the explanation environment, the proof environment is closed. This approach "works" because the scope of the redefinition of the \proofname is confined to the current TeX group and is therefore "forgotten" when the explanation environment ends.

enter image description here

\documentclass{article}
\usepackage{amsthm}

\newcommand\explanationname{Explanation} % could be made language-dependent \newenvironment{explanation}% {\renewcommand\proofname\explanationname% \begin{proof}}% {\end{proof}}

\begin{document} \begin{explanation} bla bla bla \end{explanation} \begin{proof} ble ble ble \end{proof} \begin{explanation} bli bli bli \end{explanation} \end{document}

Mico
  • 506,678
  • You've added a comment to your code saying "could be made language-dependent". How could it be made language dependent? – Evan Aad Nov 13 '22 at 10:10
  • @EvanAad - Indeed, a slightly cryptic remark. Sorry. I was thinking about how babel "knows" how to modify a slew of macros from their (generally) English-language defaults to equivalent values according to whichever language (other than English) is in the foreground. E.g., if babel is loaded and nswissgerman (hey, I'm based in Zurich!) is in effect, executing \proofname generates "Beweis" rather than "Proof". What I couldn't figure out was how to create a test of the form \newcommand\explanationname{\ifenglish Explanation\else\ifnswissgerman Erklärung\fi\fi}. [continued] – Mico Nov 13 '22 at 11:22
  • @EvanAad - Unfortunately, conditionals such as \ifenglish and \ifnswissgerman don't seem to exist. If you happen to know how to test for which language is active or "in the foreground", I think you should be almost done. My knowledge of babel and polyglossia simply isn't up to the task, I'm afraid. – Mico Nov 13 '22 at 11:28
  • 1
    @EvanAad - I just noticed that user extraordinaire egreg figured out how to employ the command \appto{\captionshebrew}{...} to get the job done. If anyone could figure it out, egreg for sure would be on that list... – Mico Nov 13 '22 at 11:33