# Latex-Completitions in Emacs

**URL:** <https://discourse.julialang.org/t/latex-completitions-in-emacs/18362>\
**Category:** New to Julia\
**Created:** [December 6, 2018, 7:46am UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362 "2018-12-06T07:46:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [December 6, 2018, 7:46am UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362/1 "2018-12-06T07:46:31Z")

</div>

In an old discussion, tpapp [suggested](https://discourse.julialang.org/t/lognormal-distribution-how-to-set-mu-and-sigma/7101/4) company-math:

> **[GitHub - vspinu/company-math: Completion back-ends for for math unicode...](https://github.com/vspinu/company-math)**
>
> Completion back-ends for for math unicode symbols and latex tags - GitHub - vspinu/company-math: Completion back-ends for for math unicode symbols and latex tags

[https://www.emacswiki.org/emacs/company-math](https://www.emacswiki.org/emacs/company-math)

However, for the life of me, I cannot get it to work.  
I am new to emacs, so I don’t really know what I am doing. But I tried a few different permutations like:

```julia
(add-hook 'after-init-hook 'global-company-mode)
(with-eval-after-load 'company
  (add-to-list 'company-backends 'company-math-symbols-unicode 'company-latex-commands))

```

OR

```julia
(defun my-julia-mode-setup ()
  (setq-local company-backends
              (append '((company-math-symbols-unicode))
                      company-backends)))
(add-hook 'julia-mode-hook 'my-julia-mode-setup)

```

based on what I’ve read online.  
I do not have a mental model of what is going on.

I can confirm that company-mode is on with `M-x company-mode`. I also tried to check the variables with `M-x customize-variable RET company-backends`, and see that the end of the list says  
`User defined: company-math-symbols-unicode`  
where `company-math-symbols-unicode` is in a text-box.

However, there does not seem to be any sort of auto-completion. For example, typing `\alpha` and then hitting [TAB] does nothing at all.

What am I missing?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 6, 2018, 8:25am UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362/2 "2018-12-06T08:25:08Z")

</div>

The relevant code snippets from my `.init.el` are

```nohighlight
(defun setup-unicode ()
  "Unicode input for the buffer."
  (interactive)
  (company-mode) ; using company-mode
  (setq-local company-backends '(company-math-symbols-unicode))
  (setq-local company-minimum-prefix-length 1)
  (setq-local company-idle-delay 0))

```

and then I call `(setup-unicode)` in the Julia setup. But I can also test and use it separately.

Are you using ESS or the standalone julia-mode?

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [December 6, 2018, 10:15am UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362/3 "2018-12-06T10:15:22Z")

</div>

I use  
(add-hook 'julia-mode-hook 'julia-math-mode)  
(add-hook 'inferior-julia-mode-hook 'julia-math-mode)

to insert Unicode math just like in latex, I find it extremely convenient.

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [December 6, 2018, 5:51pm UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362/4 "2018-12-06T17:51:19Z")

</div>

I am using ESS with julia-mode.

I did try julia-repl, but had an issue with extra close-brackets appearing when I send text from the editor to the REPL with C-RET or C-c C-c. That is, `x = [i for i in 1:4]` would send `x = [i for i in 1:4]]` to the REPL, which throws an error.  
I didn’t file an issue because I’m not sure where the problem is. It might be related to OhMyREPL. I may try removing that line from my startup.jl and retrying julia-repl later.  
Commenting here in case that is a known issue.

> I use  
> (add-hook 'julia-mode-hook 'julia-math-mode)  
> (add-hook 'inferior-julia-mode-hook 'julia-math-mode)
> 
> to insert Unicode math just like in latex, I find it extremely convenient.

Does julia-mode provide julia-math-mode?

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [December 6, 2018, 6:54pm UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362/5 "2018-12-06T18:54:25Z")

</div>

> Does julia-mode provide julia-math-mode?

Yes, I added it in [Insertion of math symbols in julia using auctex's mechanism by antoine-levitt · Pull Request #42 · JuliaEditorSupport/julia-emacs · GitHub](https://github.com/JuliaEditorSupport/julia-emacs/pull/42) by simply reusing auctex’s machinery (isn’t emacs wonderful?). It’s very convenient if you’re used to typing latex: you type “`” (or whatever character you want: I use ù because that’s easily accessible on a french keyboard and not frequently used in code) then “a” and it inserts \alpha (in latex mode) or α (in julia mode). I actually like it so much that I use it for every mode (eg email or note taking), like so:

```julia
(define-globalized-minor-mode global-math-mode julia-math-mode
  (lambda ()
    (unless (eq major-mode 'latex-mode)
      (julia-math-mode))))
(global-math-mode 1)

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 27, 2018, 7:53pm UTC](https://discourse.julialang.org/t/latex-completitions-in-emacs/18362/6 "2018-12-27T19:53:49Z")

</div>

I made a PR cleaning up the LaTeX substitutions a bit, bringing it up to date with 1.0:

[https://github.com/JuliaEditorSupport/julia-emacs/pull/67](https://github.com/JuliaEditorSupport/julia-emacs/pull/67)
