Problema ao usar o “pacote mdframed” para criar o quadro do lema

Problema ao usar o “pacote mdframed” para criar o quadro do lema

eu mudei oambiente do lemaamostra dentro domdframedpacote para criar umambiente de exemplo. Estou escrevendo em idioma persa (que tem direção RTL) usando o pacote XePersian. O problema que tenho é que a primeira letra da frase não aparece no arquivo PDF compilado final. Por exemplo, a frase começa com "برای", mas na saída final aparece como "رای", que é mostrado em retângulo vermelho na foto a seguir. Eu apreciaria se você me ajudasse a encontrar meu erro. O código que estou usando é o seguinte:

\documentclass[a4paper,11pt,aleqn]{article}
\usepackage{amsmath, mathtools}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{xepersian}
\settextfont[Scale=1]{XB Niloofar}
\setlatintextfont[Scale=1]{XB Niloofar}
\setdigitfont[Scale=0.85]{Yas}


%Lemma
\newcounter{example}[section] \setcounter{example}{0}
\renewcommand{\theexample}{\arabic{example}.\arabic{section}}
\newenvironment{example}[2][]{%
    \refstepcounter{example}%
    \ifstrempty{#1}%
    {\mdfsetup{%
            frametitle={%
                \tikz[baseline=(current bounding box.east),outer sep=0pt]
                \node[anchor=east,rectangle,fill=red!20]
                {\strut \theexample~{مثال}};}}
    }%
    {\mdfsetup{%
            frametitle={%
                \tikz[baseline=(current bounding box.east),outer sep=0pt]
                \node[anchor=east,rectangle,fill=blue!20]
                {\strut 
                    ~#1
                    :\theexample
                    ~مثال
                };}}%
    }%
    \mdfsetup{innertopmargin=5pt,roundcorner=10pt,backgroundcolor=gray!10,linecolor=green!20,linewidth=2pt,topline=true,        frametitleaboveskip=\dimexpr-\ht\strutbox\relax
    }
    \begin{mdframed}[]\relax%
        \label{#2}}{\end{mdframed}}


\title{\textbf{روش‌های جبران‌سازی}}
\date{}
\author{نویسنده }


\begin{document}
\maketitle

    
    
\section{تبدیلات ریاضی
        }
    تبدیل فوریه یک تبدیل از زمان به فرکانس است.
\begin{example}[فوریه]
برای محاسبه تبدیل فوریه  .....

\end{example}

\end{document}

Foto de amostra da saída

Responder1

Acho que a saída indesejada é porque você tem dois argumentos em seu exampleambiente e inseriu apenas um argumento e o sistema escolheu a primeira letra do seu texto como o segundo argumento automaticamente. Para mais detalhes leiaesta postagem stackoverflow.

De qualquer forma, você deve usar seu novo ambiente da seguinte forma:

\begin{example}[فوریه]{second rags} %it is not optional and it is a label for this env.
برای محاسبه تبدیل فوریه  .....

\end{example}

e você pode se referir em seu texto a este exemplo por \ref{second arg}. Você pode remover este segundo argumento modificando-o da seguinte maneira:

\newenvironment{example}[1][]{%
    \refstepcounter{example}%
    \ifstrempty{#1}%
    {\mdfsetup{%
            frametitle={%
                \tikz[baseline=(current bounding box.east),outer sep=0pt]
                \node[anchor=east,rectangle,fill=red!20]
                {\strut \theexample~{مثال}};}}
    }%
    {\mdfsetup{%
            frametitle={%
                \tikz[baseline=(current bounding box.east),outer sep=0pt]
                \node[anchor=east,rectangle,fill=blue!20]
                {\strut 
                    ~#1
                    :\theexample
                    ~مثال
                };}}%
    }%
    \mdfsetup{innertopmargin=5pt,roundcorner=10pt,backgroundcolor=gray!10,linecolor=green!20,linewidth=2pt,topline=true,        frametitleaboveskip=\dimexpr-\ht\strutbox\relax
    }
    \begin{mdframed}[]\relax%
        }{\end{mdframed}}

informação relacionada