TransWikia.com

Problem in using "mdframed package" to create lemma frame

TeX - LaTeX Asked by Bamzi on February 27, 2021

I have changed the lemma environment sample inside the mdframed package to create an example environment. I am typesetting in Persian language (which has RTL direction) using XePersian package. The problem I have is that the first letter of the sentence does not appear in the final compiled PDF file. For example the Sentence starts with "برای" but in the final output it appears like "رای" which is shown in red rectangle in the following photo. I would appreciate if you help me to find my mistake.
The code that I am using is as follow:

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-htstrutboxrelax
    }
    begin{mdframed}[]relax%
        label{#2}}{end{mdframed}}


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


begin{document}
maketitle

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

end{example}

end{document}

Sample photo of the output

One Answer

I think the undesired output is because of you have two argument in your example environment and you entered just one argument and the system picking the first letter of your text up as the second argument automatically. For more details read this stackoverflow post.

Anyway, You should use of your new environment as follow:

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

end{example}

and you can refer in your text to this example by ref{second arg}. You can remove this second arg by modifying it as follow:

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-htstrutboxrelax
    }
    begin{mdframed}[]relax%
        }{end{mdframed}}

Correct answer by user108724 on February 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP