This is edit. See original question below.

In math mode I would like to use identifiers that contain of whole word. That word is not in English and does contain letters with diacritic marks. Example of such word is kľúč.

I have tried to use commands like \mathit{kľúč} or \mathnormal{kľúč} inside math environment. They work well when there are no diacritic marks for example \mathit{kluc} renders the word together with no ugly spaces between letters. When diacritic marks are present the letters are rendered with spaces for example command \mathit{kľúč} inside math environment produces something like k ľ úč instead of klúč.

How can I typeset multi-letter identifiers that contain diacritic marks inside math environment?

Original question text:

The title says it. I want to use letters like ľ, ú, š, ô etc. as part of mathematical identifier (\mathit) in math environment. However unlike standard english letters they are rendered with unpleasant spaces before and after them. How do I solve this?

Example of used command:

$\left\langle \mathit{kl\mkern-5mu\mathchar19\acute{u}\check{c}},\mathit{hodnota}\right\rangle $

This is LaTeX code produced by Lyx when I edit that expression using graphical editor. Expected output is something like <kľúč, hodnota> (in english this would be <key, value>) but what I get looks more like <k ľ ú č, hodnota>.

  • 3
    Why do you use \mathit at all? math mode tells latex that all normal letters (i.e. the ones with no mathematical significance) are variables and get bigger spacing. I doubt that's what you want. On top of that the $ already starts math mode and usually math is set italic/slanted. Are you sure you don't want \textit? – Max Dec 30 '12 at 19:20
  • @Max No I'm not. But I need to use mathematical expressions (or pseudo-code programatic expressions) and in those I want to use multi-letter identifiers. Those multi-letter identifiers will contain also letters with diacritics marks. Al the letters in those identifiers must be rendered together with no space between them. That is what I want to do, but I do not know how. – Rasto Dec 30 '12 at 19:33
  • @drasto You can (and should) use \textit in math mode. If you load amsmath also \textit will change size in subscripts and superscripts. – egreg Dec 30 '12 at 19:58

The characters allowed in \mathit are just plain ASCII, with possibly math accents over them. For words it's better to use \textit, which will change size in subscripts and superscripts, provided amsmath is loaded.


$\langle\textit{kľúč}, \textit{hodnota}\rangle$


enter image description here

If LyX is unable to provide \textit, then it's a problem of LyX, not of LaTeX.

  • I really thank you for this answer. @barbara beeton's was good but yours works with Lyx well and is very simple. Only minor point is that it does not display perfectly in Lyx editor but I can live with that. Thank you! – Rasto Dec 30 '12 at 21:13

it looks to me as if this is really text, not math.

if you have many such constructions, i suggest creating a macro something like this to take care of them:

  \langle\text{\textit{#1}, \textit{#2}}\rangle}

this will require \usepackage{amsmath} which defines \text. it would be used this way, and works only within a math environment:

... \mykeyval{xxx}{yyy} ...

only the angle brackets are really math; \text allows you to embed text strings in math environments. i prefer non-italic commas in such situations, which is why i exited from italic for the comma.

(an earlier version of this answer suggested a construction that is used by tugboat to enter pseudocode, but that, in its usual formulation, doesn't work properly within \text embedded in a math environment, so the suggestion has been removed here.)

  • Example in my question is really an example. It need to use multi-letter identifiers containing letters with dicritics marks inside complex mathematical expresions. And I prefer them to be italic as proper in mathematical formulas. I would prefer not to exit math environment and set italics every time I use such identifier because that would probably make LaTeX code one big mess. – Rasto Dec 30 '12 at 19:47
  • Looks like it works. I defined new macro \newcommand{\mathid}[1]{\text{\textit{#1}}} and then used $\left\langle \mathid{kľúč},\mathit{hodnota}\right\rangle $. This works as expected. My problem is that now it looks like I'll have to edit all formulas in plain LaTeX because when using Lyx editor it keeps changing same expression to something like $\left\langle \mathid{kl\mkern-5mu\mathchar19\acute{u}\check{c}},\mathit{hodnota}\right\rangle $. And this does not even compile saying: I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed. – Rasto Dec 30 '12 at 20:55
  • @drasto -- i've updated the answer to use the formulation you said worked, and also my comment. – barbara beeton Dec 30 '12 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.