Oskar-Idland / vscode

0 stars 0 forks source link

Cant manage to get it to work #1

Open calsamig opened 2 weeks ago

calsamig commented 2 weeks ago

I dont get how it is ment to work. I see some snippets that generate non-latex symbols, e.g ß. that dont appear in the pdf when I compile. Could you provide an example of use in a latex file, and indicate what extensions or config are required?

Oskar-Idland commented 2 weeks ago

Yes, that is a LaTeX issue. You are welcome to just replace it with \beta, but I find it easier to read this way. I use the unicode-math package for this. image

If you install the "Fast Unicode Math Characters" extension, you can write any special character like \beta, then press space, and you get the actual ß.

I also really recommend the "Ultra Math Preview" extension which gives you this small box which updates as fast as you type. This lets you compile less often, and spot small mistakes wayyy quicker.

Another very useful extension is the "Conceal" extension, which lets you hide a lot of LaTeX, making it prettier and easier to read. It can be toggled if you want to debug some syntax mistake. It makes this: image Become this: image Where all replacements are configurable.

calsamig commented 2 weeks ago

nice! it does work smoothly with xelatex, but my docs often need to be compiled in pdflatex. So, I'll convert math unicode to latex command as you suggest.

Oskar-Idland commented 2 weeks ago

It's a long time since I used pdflatex. To reproduce the above, you can use both ucs with the "mathletters" option, and the inputenc with the "utf8x" option:

\documentclass{article}
\usepackage{physics}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\author{Oskar Idland}
\title{Test Document}
\date{}
\begin{document}
\maketitle
\[
iℏ \frac{∂}{∂t} \ket{ψ} = \hat{H} \ket{ψ}
\]

\[
\left<E\right> = \bra{ψ}\hat{H}\ket{ψ} = ∫_{-∞}^{∞} ψ^{*}\hat{H}ψ \ \mathrm{d}x
\]

\end{document}
calsamig commented 2 weeks ago

any way to make an exception within math context? For instance I would like to be able to type a free text without triggering math snippets when adding the label, e.g. \label{aaa}, in an equation or writting a text within an equation with \mbox{} , \mathrm{}.

Oskar-Idland commented 2 weeks ago

If a snippet has the m-flag, it only activates in a math context. When you have non-math context like \text{} or \mathrm{} it doesn't activate.