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.

10
  • 1
    @Mico Isn't this essentially the same solution as here?
    – Evan Aad
    Nov 13, 2022 at 6: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, 2022 at 6:53
  • 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, 2022 at 7:02
  • 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, 2022 at 7:45
  • 1
    @Mico Voilà.
    – Evan Aad
    Nov 13, 2022 at 8:21

1 Answer 1

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}
4
  • 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, 2022 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, 2022 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, 2022 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, 2022 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .