# Tag Info

Accepted

The Emacs Lisp constant pi is not actually the number ð. Rather, the Emacs Lisp constant pi is an approximation to ð, good to about 16 digits -- pi is exactly 3....

I think this is simply the expected answer. As a float, 1.2246467991473532e-16 is not different from zero, given the floating point error Emacs Lisp can handle. One get the same answer in R for ...
• 1,144
Accepted

### How to insert mathematical symbols in emacs

You can set the insert method with M-x set-input-method RET tex. Then type \beta and watch it get converted. It can be toggled and set with C-\! Tested and confirmed that it compiles and renders ...
• 556

You are doing nothing wrong. This function is working with floating point numbers which have good, but limited, accuracy. 1.2246467991473532e-16 is pretty close to 0 (0.0... with 15 zeros before the ...
• 3,920
Accepted

### How can I convert a Lisp expression to a LaTeX math expression?

Here is a toy function: (defvar lisp2latex-need-parens nil) (defun lisp2latex (form) (pcase form ((+ . ,args) (let ((ret (let ((lisp2latex-need-parens nil)) (mapconcat #'...
• 6,144
Accepted

### Convert percent to decimal: (/ PERCENT 100)

Your workaround tells the whole story: (/ 1 2) ;=> 0 (/ 1.0 2) ;=>0.5 With integers, emacs does integer arithmetic, with floats it does floating-point arithmetic. See the Elisp manual, node ...
• 3,920
Accepted

### Cube root in elisp

There are a couple of ways: (expt 8 (/ 1.0 3.0)) â 2.0 Or, if you want symbolic results: (require 'calc-arith) (calcFunc-pow 8 (calcFunc-inv 3)) â (float 2 0) (calcFunc-pow 8 (calcFunc-inv (list 'x)))...
• 18.6k

### How to insert mathematical symbols in emacs

I love the accepted answer, but I also wanted to point out that you can insert unicode characters by name using C-x 8 RET. This will bring up a selection list in the minibuffer that lets you type the ...
• 283
Accepted

### How get decimal values?

Assuming you're happy with floating point arithmetic then you just need to make one of the numbers a float. e.g.: (/ 15.0 6) => 2.5 Refer to C-hig (elisp)Arithmetic Operations each of these ...
• 52.1k

### Using string-to-number causes rounding/precision issue for specific floating point values

What Every Programmer Should Know About Floating-Point Arithmetic is an excellent guide to understanding floating point numbers. I thoroughly recommend reading that in full -- I think it will answer ...
• 52.1k
Accepted

### How can you automatically translate fractions into their short unicode versions? e.g. â

You could use prettify-symbols-mode with something, evaluable in your sratch buffer, like this: (progn (push '("2/3" . ?â) prettify-symbols-alist) (prettify-symbols-mode -1) (prettify-symbols-...
• 2,664

### How can you automatically translate fractions into their short unicode versions? e.g. â

If you're willing to have the text change, you can use one of Emacs' many input methods. With e.g. rfc3145, you could type that as &23 or with TeX it would be \\frac23 Use C-\ to choose your ...
• 5,375

### Insert trigonometric function to org file

Yes, by using Latex and preview that. Have a read at the org-mode manual org-latex-preview section. There are embedded formulae like $\sin(r) = 3\sin\left(\frac r3\right)-4\sin^3\left(\frac r3\right)$...
• 4,656

### Replace text with latex

Go to the beginning of your text and press C-M-%. That key sequence is bound to the command query-replace-regexp. Give $$[+-]?[0-9]+\|\_<[[:alpha:]]$$/$$[+-]?[0-9]+\|[[:alpha:]]\_>$$ as search ...
• 33.4k
1 vote

### change environment in evil-tex

From the documentation, the environment keymap for multiline* is M. So for example from inside your equation environment in evil-normal-state, you can change the equation environment to multiline* ...
1 vote

### How do I convert a matrix in one form to a matrix in another form (like bmatrix environment)

I suggest you use Calc. You can set language mode to latex, temporarily by opening a Calc session, or permanently by saving the configuration in the calc.el file. Enable calc-embedded when the point ...
• 2,253
1 vote

### How do I convert a matrix in one form to a matrix in another form (like bmatrix` environment)

EDIT There is/was a bug in the replace-string-in-region function. Using the newest version of that function, your code works alright, except for some unwanted newlines due to the first backslash in ...
• 7,910
1 vote
Accepted

### LaTeX fragments look different to exported PDF (witharrows)

Thanks to @NickD I have found a solution. The solution is to register a custom org-preview-latex-process and run pdflatex/lualatex twice for generating the latex preview image: (setq luamagick '(...
1 vote

### LaTeX fragments look different to exported PDF (witharrows)

[Not a complete answer: in the first part, I show the TeX file for the preview and identify the problematic component of the pipeline, but I don't know why that component misbehaves. In the second ...
• 31.8k
1 vote
Accepted

### Key sequence to automatically make math-mode fragments in org-mode?

I have a yasnippet for this: # -*- mode: snippet; require-final-newline: nil -*- # name: math for Org # key: $$# binding: direct-keybinding # -- \$$1\$$ 0 I type$$ and get what you want: $$_$$.
• 4,256
1 vote
Accepted

### Use LaTeX accents with tex insert method

M-x describe-input-method RET tex RET will tell you the (somewhat depressing) news: lots of letters can be "hatted" but they are Latin letters only. Input methods are limited in the kind of ...
• 31.8k
1 vote
Accepted

### Remove math fragments from buffer in org mode

Just use an C-u prefix: From the docs: (org-latex-preview &optional ARG) Toggle preview of the LaTeX fragment at point. If the cursor is on a LaTeX fragment, create the image and overlay it over ...
• 1,139
1 vote
Accepted

### Labelling LaTeX sub-equations in org-mode

Your question is a little bit ambiguous - while the snippet in your link provides numbering as (1a), (1b), you ask for specific like (a), (b). Both versions are possible, as below. To solve, you ...
• 1,713
1 vote
Accepted

### Customize org babel execution command in C

Use the :flags or :libs header to pass flags to the compiler (or libraries to the linker): #+begin_src C :libs -lm #include <stdio.h> #include <math.h> int main(){ printf("Square = %f",...
• 31.8k
1 vote

### Evaluate algebraic formula in the buffer in place

For reference I'm posting my solution based on wasamasa's answer: (save-excursion (beginning-of-line) (if (re-search-forward " *=.*" (line-end-position) t) (replace-match "")) (end-of-...
• 1,270
1 vote
Accepted

### Evaluate algebraic formula in the buffer in place

calc provides calc-eval for this kind of use, just pass it a string and receive a string result back.
• 22.3k

Only top scored, non community-wiki answers of a minimum length are eligible