Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.7K Views
|
5 Replies
|
1 Total Like
View groups...
Share
Share this post:

Self-introduced integral sign being multiplied to the numerator in Latex?

Posted 3 years ago
POSTED BY: Albert Lew
5 Replies

Gather the whole integrand into a RowBox:

expr = With[{f = Sin[Pi Sqrt[x^2 + y^2]]/Sqrt[x^2 + y^2], 
   reg = (1 <= x^2 + y^2 <= 4)}, 
  DisplayForm@
   InterpretationBox[
    RowBox[{UnderscriptBox[StyleBox["∬", FontSize -> 24], reg], 
      RowBox[{f, RowBox[{"\[DifferentialD]", x}], 
        RowBox[{"\[DifferentialD]", y}]}]}],
    Integrate[f, Element[{x, y}, ImplicitRegion[reg, {x, y}]]]]]
expr // TeXForm
POSTED BY: Gianluca Gorni

You can use replacement rules. The rule depends on what sorts of integrals you have and the way you write them. Suppose that you write the integration region with the syntax Element[{x,y},ImplicitRegion[inequalitites,{x,y}]]. Then you can do this way:

replacementRule = 
  Integrate[f_, Element[{x_, y_}, ImplicitRegion[reg_, {x_, y_}]]] :> 
   DisplayForm@
    InterpretationBox[
     RowBox[{UnderscriptBox[StyleBox["∬", FontSize -> 24], reg], 
       RowBox[{f, RowBox[{"\[DifferentialD]", x}], 
         RowBox[{"\[DifferentialD]", y}]}]}], 
     Integrate[f, Element[{x, y}, ImplicitRegion[reg, {x, y}]]]];
mySampleDoubleIntegral = 
  Integrate[Sin[\[Pi] Sqrt[x^2 + y^2]]/Sqrt[x^2 + y^2], 
   Element[{x, y}, ImplicitRegion[(1 <= x^2 + y^2 <= 4), {x, y}]]];
mySampleDoubleIntegral /. replacementRule

The same integral can be written with other styles, for example with Boole, which may require different rules. You may also want to make rules for Inactive[Integrate].

It is hard to know what you have in mind form a single example.

POSTED BY: Gianluca Gorni
Posted 3 years ago

Thanks, Gianluca, for your insight. Your code works since I had defined the latex string for those special self-introduced integral signs in my notebook before I posted the question here. But the thing is: I do not want to rearrange the boxes by hand and by sight each time I need to do this kind of conversion. Because there can be a ton of integrals of this kind in one notebook of mine. What I need is a way to automate the process, like a function associated with MakeBoxes[] so that every time I do the conversion, Mathematica can recognize it is an integral sign and can not be multiplied into the numerator automatically.

If you have any idea on the automation of the process, I am all ears.

POSTED BY: Updating Name

No, not out of the box. You have to replace \unicode{222c} with {\int\!\!\int}:

StringReplace[expr // TeXForm // ToString, 
 "\\unicode{222c}" -> "{\\int\\!\\!\\int}"]
POSTED BY: Gianluca Gorni

I tried putting your LATEX in here or here, doesn't work?

POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard