1

I'm trying out calc-embedded feature to write evaluate/manipulate equations in calc then write the output to my latex/org buffer.

In calc, one can change the display mode to LaTeX with d L (or calc-latex-language). It's so GREAT so convenient.


However the calc-latex-language in calc uses \times symbol for the multiplication (e.g. c \times (a + b) 1-st row of image below). I much prefer \cdot notation (2-nd row of image below).

enter image description here


I can change \times with \cdot after every time equation is imported from calc. However, this seems bit inconvenient.

Quesiton:

  • Is there way to change the calc-latex-language settings so that that calc uses \cdot in the first place instead of \times?

Update/Info:

It might be something to do with below in the ‘calc-lang.el’.

(put 'tex 'math-oper-table
  '( ( "\\hat"    calcFunc-hat     -1  950 )
             ...
     ( "\\times"  *        191 190 )            <-- may be this line????
     ( "*"        *        191 190 )
              ...

Being unable to read/write elisp, I can do nothing more.

2 Answers 2

1

I realized fixing this from the latex side (changing symbol behind \times) is far more easier than customizing it from calc's LaTeX display mode.

So I asked it from TeX stack exchange about how to redefine \times. Thanks to Οὖτις's answer adding following line to TeX file will make this work.

\let\oldtimes\times
\let\times\cdot

for Org-File

#+begin_export latex
\let\oldtimes\times
\let\times\cdot
#+end_export

Now \times will symbol behind \cdot, and \oldtimes will show symbol behind original \times.

0

Short Answer

Execute the following code so that LaTeX's \cdot is interpreted as a multiplication in calc (or preferably add it to your init.el):

;; Interpret LaTeX \cdot as multiplication symbol in calc
(with-eval-after-load 'calc-lang
  (let ((original-value (get 'latex 'math-oper-table)))
    ;; Append a new value to the list
    (put 'latex 'math-oper-table
         (append original-value
                 '(( "\\cdot" * 191 190))))))
 

Long Answer

Investigating calc-lang.el, the mapping of the LaTeX \times argument with calc's multiplication is saved in the math-oper-table property of the tex package (I left out other mappings):

(put 'tex 'math-oper-table
'( ( "\\times"        *        191 190 )))

This math-oper-table property is then used for the same property of the latex package with appending additional property values (again, I left out other mappings and included only one additional LaTeX only mapping).

(put 'latex 'math-oper-table
     (append (get 'tex 'math-oper-table)
             '(( "\\Hat"    calcFunc-Hat     -1  950 )

We can now append an own entry in the same fashion presented in the first code block. Essentially, we retrieve the current property value, locally bind it using let and overwrite the original property with its original value appended by an additional entry. This new entry maps \cdot with the multiplication symbol in calc. All of this is only executed after the original properties have been created. That is accomplished with with-eval-after-load.

Your Answer

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

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