Why can't I show the ð symbol in LaTeX? - unicode

I can use \DeclareUnicodeCharacter{0278}{\phi} and then $ɸ$ to display the ɸ symbol in LaTeX. However, when I try to use:
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{0360}{\eth}
\begin{document}
$ð$
\end{document}
ð doesn't display. Why doesn't this work?

You need
a package which provides the \eth macro in the encoding you are using, e.g. stix
the \eth macro from this package is, unlike \phi, a text macro and not a math macro, so either use it outside of a math environment or surround it with \text{..} from the amsmath package
if your tex distribution is not totally out of date, you don't need \usepackage[utf8]{inputenc}, that's the default since a couple of years
\documentclass{article}
\usepackage{amsmath}
\usepackage{stix}
\DeclareUnicodeCharacter{0360}{\eth}
\begin{document}
ð
$\text{ð}$
\end{document}
or avoid all the trouble and simply use an unicode aware engine like lualatex:
% !TeX TS-program = lualatex
\documentclass{article}
\begin{document}
ð
\end{document}

Related

Is there a Unicode that a dot inside the equal symbol?

dotequal
I need this symbol. I've searched for it but can't find its unicode. All I can find is ≐ ,≑ and ≖, but what I need is a dot inside the equal, not above or around or a ring inside.
Here is its latex.
\documentclass{article}
\usepackage{MnSymbol}
\usepackage{amsmath}
\DeclareMathOperator{\equaldot}{\mathrel{=\hskip-0.64em\cdot\hskip0.15em}}
\begin{document}
\[
a \equaldot b
\]
\end{document}
from
In latex, how to type a math symbol that is an equal sign with a dot in the middle?
If there isn't such a Unicdoe, is there a way to combine two symbols = and · together?
That's to say, is there a way to make two Unicode stack together?
You can define that symbol on your own. Here's a possible solution:
\newcommand*{\defeq}{\def\arraystretch{0}\begin{array}{c}
\overline{\underline{\,.\,}}
\end{array}}

vscode markdown preview not supporting some math commands

I'm writing markdown on vscode. But some math latex commands are not supported on vscode built-in preview. E.g.
$$ \ket{\psi} $$
cannot be properly rendered. How do I fix this? How do I add support to a bigger set of commands? Are there any extension that does this for me?
I installed markdown + math extension, but still not working for \ket command. Also for some reason, markdown + math's official example for equation numbers supporting is not working. I don't understand why.
VSCode 1.58 (June 2021) will support math equations rendering in markdown:
Math formula rendering in the Markdown preview
VS Code's built-in Markdown preview can now render math equations using KaTeX
Inline math equations are wrapped in single dollar signs:
Inline math: $x^2$
While you can create a math equation block with double dollar signs:
Math block:
$$
\displaystyle
\left( \sum_{k=1}^n a_k b_k \right)^2
\leq
\left( \sum_{k=1}^n a_k^2 \right)
\left( \sum_{k=1}^n b_k^2 \right)
$$
You can set "markdown.math.enabled": false to disable this feature.
It even comes with:
Markdown math formula syntax highlighting
We now also support highlighting of math equations in Markdown source:
This works both in normal markdown files and in Markdown cells inside notebooks.

Add math symbols in an annotation

How can I added a note on a figure plot in Matlab which contain math symbols (kappa, gamma, alpha, symbol of containing, ...) as explained in the image:
You can add a text label using the text command.
For example
plot(0:10, (0:10).^2);
% Add text at x=5, y=10
text(5, 10, 'this is text');
% Add text at x=5, y=50, with Greek letters
text(5, 50, '\pi is nice, \alpha is too');
This works because the interpreter is set to LaTeX by default. For the full list of supported TeX commands, see this list in the documentation. In particular, since you asked about Greek letters, here is a basic list. Most are as you would expect, preceded by a backslash:
Character Sequence Symbol
\alpha α
\beta β
\gamma γ
\delta δ
\epsilon ɛ
\zeta ζ
\eta η
\theta Θ
\kappa κ
\lambda λ
\mu µ
\xi ξ
\pi π
\rho ρ
\sigma σ
Notes on the LaTeX interpreter.
You can also render maths inside text captions (or axes labels, and chart titles) using $inline mode$ or $$display mode$$. See the linked docs for more details.
You can set the default interpreter to LaTeX (if for some reason it isn't) using
set(0,'defaulttextinterpreter','latex')
The default interpreter is already latex so all you have to do is something like this as an example. not the backslash to access the latex commands. You will have to search what symbols you want on the internet.
legend('\rho = 0.5')

How does matlab's latex interpreter handle unicode?

I'm wondering how MATLABs latex interpreter for plot text deals with unicode characters? It is weirdly inconsistent. Which, y'know, invalidates the whole ENTIRE point of unicode.
TOY CODE
%*** Setup some text for a plot title
Title_Txt{1} = [char(8734) ,' SNR~~~' , char(10) , '(-)'];
Title_Txt{2} = ['50 SNR~~~' , char(10) , '(-)'];
%*** Plots!
x= 1:1:10
y= rand(size(x))
figure(1)
subplot(211)
plot(x,y)
title(Title_Txt{1} , 'interpreter' , 'latex')
subplot(212)
plot(x,y)
title(Title_Txt{2} , 'interpreter' , 'latex')
Toy code demonstrates that the latex interpreter handles char(10) --- a new line. But it breaks from char(8734) --- the infinity symbol.
Obviously I can work around this by feeding in a latex symbol that matlab knows (another source of frustration but that's for a different discussion), but I am curious about
what MATLAB is doing under the hood here?
is there is a fix for getting unicode into latex?
I suspect the (unsatisfying) answer here is that the Latex interpreter portion of Matlab does whatever the included version of Latex does, and Latex in general doesn't support Unicode. (For Latex solutions, see: https://tex.stackexchange.com/questions/34604/entering-unicode-characters-in-latex. Of course this doesn't help Matlab users.)
As to why Latex doesn't support Unicode. I'll note that the first copyright date on my Latex users' guide is 1985, and the latest release is version 2e, from 1994. Unicode was not really mainstream until the '90's.
(This is a poor answer, but became too long for a comment.)

Surface plot with LaTeX code in label

I would like to use the Letter μ (LaTeX: \mu) in my surface plot. Unfortunately when I use the LaTeX symbol \mu in the zlabel('Power [\muW]'); command it results in:
'Power [ μ W]' instead of 'Power [μW]'
How can I avoid these spaces around μ?
I can't reproduce your problem, which could be due to you using an older version of Matlab. In the past it was neccesary to set the latex interpreter fist, before using Latex syntax. So the following should work:
zlabel('Power [$$\mu$$W]','interpreter','latex');
Nowadays it seems to recognize automatically at least greek letters.