2
$\begingroup$

In Mathematica,the inverse hyperbolic functions are displayed with the prefix "Arc" like "ArcSinh[]", which I thought incorrect and misleading. Since the hyperbolic angle is defined by the area of the hyperbolic triangle rather than the arclength of a sector like the radius angle in trigonometric functions, the more appropriate prefix "Ar" abbreviated for "Area" like "ArSinh" looks much more satisfactory and pleasant to me. As a result, I have defined my own form of inverse hyperbolic functions as below (To save space, only take the ArSinh[] as an example):

1.Make any result including inverse hyperbolic functions display in the way I prefer:

Unprotect[ArcSinh];MakeBoxes[ArcSinh[x_], fmt_] := MakeBoxes[ArSinh[x], fmt];

2.Make my input including inverse hyperbolic functions passed to the system in the default and original way so that the system can evaluate them correctly instead of being strange to them and returning them unchanged:

$PreRead =# /. {"ArSinh" -> "ArcSinh"}&

The 2 steps above work perfectly so far. But then I encountered my puzzle:how can I make the Mathematica convert the inverse hyperbolic function I defined to TeXForm the way I prefer?

Currently, Mathematica converts the ArSinh[x] to TeXForm as "\text{ArSinh}\left(x\right)" i.e. $\text{ArSinh}\left(x\right)$ which is not canonical in LaTex. I would like Mathematica to converts the ArSinh[x] to TeXForm as "\sinh^{-1}(x)" i.e. $\sinh^{-1}(x)$ or"\text{arsinh}(x)"i.e. $\text{arsinh}(x)$ .

Moreover, preset built-in rules to convert inverse trigonometric functions to TeXForm are converting them to the form of the -1 power of the original function name like ArcTan[x]$\tan^{-1}(x)$, which might be ambiguous in some way. I would like to define my own rule to convert the inverse trigonometric functions as arc+the original function name like "\arctan(x)"i.e. $\arctan(x)$ or "\text{arctan}(x)"i.e. $\text{arctan}(x)$.

I hope the way to achieve those above works well when I right click->copy as->LaTeX as well as save the notebook in TeX format entirely.

Is there any good way to realize those goals?

$\endgroup$
1
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Aug 31, 2021 at 16:21

1 Answer 1

4
$\begingroup$

Using the approach of my answers to TeXForm and large brackets (\Biggl[ etc) and TeXForm: control processing spelt-out names of Greek letters:

Convert`TeX`BoxesToTeX; (* initializes $GreekWords on autoload *)

If[! MatchQ[oldGreekWords, _List], 
 oldGreekWords = System`Convert`TeXFormDump`$GreekWords];

mytexrules = {SuperscriptBox["sinh", RowBox[{"-", "1"}]] -> 
    "\\text{ArSinh}",
  "ArSinh" -> "\\text{sinh}^{-1}"};
If[MatchQ[oldGreekWords, _List], 
  System`Convert`TeXFormDump`$GreekWords = Join[mytexrules, oldGreekWords], 
  "Warning: System`Convert`TeXFormDump`$GreekWords not initialized"];

ArcSinh[x] // TeXForm

\text{ArSinh}(x)

ArSinh[x] // TeXForm

\text{sinh}^{-1}(x)

Add more rules to get other conversions. Delete ones that are not desired. I wasn't completely sure what was wanted.

$\endgroup$
5
  • $\begingroup$ Thanks Michael, for your help! I have tested your code and it works effectively when TeX code was output by using the function TeXForm[]. However, when I right click->copy as->LaTeX as well as save the notebook in TeX format entirely, your code simply does not work. Other methods that works under the two circumstances mentioned are greatly appreciated. $\endgroup$
    – AlbertLew
    Sep 1, 2021 at 5:24
  • $\begingroup$ @AlbertLew Did you try the advice at the end of the second answer I linked (mathematica.stackexchange.com/a/132069)? $\endgroup$
    – Michael E2
    Sep 1, 2021 at 11:43
  • $\begingroup$ Thanks for your suggestion. I have read that post you linked and tried setting the option that matters. And I am very glad to tell you that after the option set it works like a charm, totally realizing my expectation, so I have accepted your answer. $\endgroup$
    – AlbertLew
    Sep 2, 2021 at 11:26
  • $\begingroup$ By the way, I read the the other post you mentioned at the beginning, and learned from it, which has enabled me to set further converting rules related to the already built-in functions, such as the inverse trigonometric function(ex. ArcCos[x]->$arccos(x)$) and natural logarithm function(ex.Log[x]->$\ln(x)$). Thanks for your enlightening answers in those posts. $\endgroup$
    – AlbertLew
    Sep 2, 2021 at 11:34
  • $\begingroup$ @AlbertLew You're welcome. Thank you for the accept. $\endgroup$
    – Michael E2
    Sep 2, 2021 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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