(This answer is based on a previous answer of mine from another problem : my previous answer)
The solution is to use the literate
option within the lsset
command. I modified your code (note that you need only enter $
and not \$
in the actual code listing. For visual purposes, I included a coloring for the $ but you may change it to suit your needs.
\documentclass[12pt,oneside,a4paper]{scrartcl}
\usepackage{textcomp}
\usepackage{listings}
\usepackage{color}
\definecolor{lightgray}{rgb}{.9, .9, .9}
\definecolor{darkgray}{rgb}{.4, .4, .4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}
\lstdefinelanguage{JavaScript}{
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
keywordstyle=\color{blue}\bfseries,
ndkeywords={class, export, boolean, throw, implements, import, this},
ndkeywordstyle=\color{darkgray}\bfseries,
identifierstyle=\color{black},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
commentstyle=\color{purple}\ttfamily,
stringstyle=\color{red}\ttfamily,
morestring=[b]',
morestring=[b]"}
\lstset{
language=JavaScript,
backgroundcolor=\color{lightgray},
extendedchars=true,
basicstyle=\footnotesize\ttfamily,
showstringspaces=false,
showspaces=false,
numbers=left,
numberstyle=\footnotesize\ttfamily,
numbersep=9pt,
tabsize=2,
breaklines=true,
showtabs=false,
frame=leftline,
caption=\lstname,
literate={\$}{{\textcolor{blue}{\$}}}1
}
\begin{document}
\begin{lstlisting}[name=Beispiel mit JavaScript Bibliothek (jQuery)]
$("p").elements.each(function() {
$(this).html = "Element erkannt";
});
\end{lstlisting}
\end{document}
The result is
FF Seria Pro [Is this the correct font?] seems to not have the glyph ḥ
:
Neither the online preview shows it, nor does it appear on one of the three pages of the “complete character set”.
Possible solutions:
- You take
ḥ
from another font that is as close to Seria Pro as possible. (Bad)
You mimick it (build it yourself).
With the help of the calc
you could do:
\makebox[\widthof{h}][c]{\raisebox{-.45ex}{.}}\llap{h}
Or, of course, make it your own macro:
\newcommand*\doth{\makebox[\widthof{h}][c]{\raisebox{-.45ex}{.}}\llap{h}}
Or, if you want to use the original char ḥ
(it's XeLaTeX after all), make it active:
\catcode`\ḥ=\active
\newcommand*{ḥ}{\makebox[\widthof{h}][c]{\raisebox{-.45ex}{.}}\llap{h}}
You may adjust the dimension -.45ex
so that it looks good.
You use another font.
This may be the best choice if you need to typeset a lot of those “funny” characters that don't exist in the chosen font!
If you need a lot of “under-dotted” characters you might even want to redefine the existing \d
macro to
\renewcommand*\d[1]{\makebox[\widthof{#1}][c]{\raisebox{-.45ex-\depthof{#1}}{.}}\llap{#1}}
Best Answer
I just solved it in using
I hope it can help some in the same case than me.