2

Please believe me this is not an Off Topic in TEX. Wait and see that I SEARCH the web and go deeply into questions for this but nothing found:

Can we equip ‎AtBeginEnvironment with two option simultaneously? I mean I want to have something like:

\AtBeginEnvironment{example}{‎‎\small}

which make whole examples a bit smaller in fonts, merged with the code \emph which make the whole body inside example environment unitalic.

What I did is:

‎‎\begin{example}‎‎
\emph{ John Smith}
\end{example}

to do so. Thanks for the hints.


Cosidering David's comment, I added my MWE as follows. It does not work as suggested. Maybe there is a defect in xepersian not working properly. See this plz:

\documentclass[a4paper,openany,12pt]{book}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage{geometry}\geometry{text={7in,9.5in},headheight=15pt}
\geometry{left=40.5mm,right=44.5mm,top=61mm,bottom=51mm}
\usepackage{mdframed}\usepackage[computeautoilg=off]{xepersian}
\settextfont[Scale=1.1]{XB Niloofar}\setdigitfont[Scale=1.3]{IRXLotus}
\setlatintextfont[Scale=1.2]{Times New Roman}
\newtheorem{example}{مثال}[chapter]
\AtBeginEnvironment{example}{‎‎\small\upshape}
‎\linespread{1.5}
‎\begin{document}
‎\begin{example}
با حل دستگاه، ‎$A=4$‎ و ‎$B=5$‏ و ‎لذا‎ داریم:
$$‎
\displaystyle\int f_2(x)~dx=\displaystyle\int \dfrac{4}{x-3}~dx-
\displaystyle\int\dfrac{5}{-2+x}~dx=
underbrace{4\ln|x-3|-5\ln|-2+x|}_{\ln~\left|\dfrac{(x-3)^4}{(x-2)^5}\right|}+C
$$‎
\qed
\end{example}
\end{document}

I hope every one can copy the codes and run it personally. If you do that, you will the Persian words are still italic, however, I did the suggested codes.

4
  • @campa Thanks. I does not change. It is still `small' (which is OK) and is still 'italic' (which is not of interest).
    – Mikasa
    Aug 1 '19 at 11:13
  • @campa Is it possible that some packages make bad effects such that your code does not work properly? Something like conflicting with each other?
    – Mikasa
    Aug 1 '19 at 11:22
  • @DavidCarlisle: Thanks David for your hints. Thanks for the time. I'll do what you said in the next time and obey.
    – Mikasa
    Aug 1 '19 at 12:10
  • 1
    Your example gave a lot of errors due to unicode control characters and if I remove them I do not have the fonts, but you do not want to use AtBeginEnvironment here at all. you have defined the example environment so you can define it not to be italic, see the amsthm package theoremstyle commands. Aug 1 '19 at 15:49
7

The amsthm package provides several "theorem styles". While the default style, also known as the plain style, is programmed to typeset its body in italics, the remark and definition styles employ upright lettering. I therefore suggest that you insert the instruction

\theoremstyle{definition}

after loading amsthm and before issuing the instruction

\newtheorem{example}{مثال}[chapter]

(I'm afraid I can't run your MWE as two required fonts -- XB Niloofar and IRXLotus -- are not installed on my system. Sorry.)

4
  • 1
    Thanks I didn't have time to post a proper answer (after I changed the question:-) Aug 1 '19 at 16:50
  • Great! Thanks for your consideration. +1
    – Mikasa
    Aug 1 '19 at 16:56
  • 1
    @DavidCarlisle Thanks David for making the right title and for strong light on my question. You were the pioneer.
    – Mikasa
    Aug 1 '19 at 16:57
  • @DavidCarlisle - Thanks, David. You figured out what the OP's main issue was -- nothing to do with options being specified in an \AtBeginEnvironment directive...
    – Mico
    Aug 1 '19 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.