Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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>.

share|improve this question
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. –  drasto 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

2 Answers 2

up vote 4 down vote accepted

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.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[slovak]{babel}
\usepackage{amsmath}

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

$A_\textit{kľúč}$
\end{document}

enter image description here

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

share|improve this answer
    
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! –  drasto 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:

\newcommand{mykeyval}[2{%
  \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.)

share|improve this answer
    
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. –  drasto 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. –  drasto 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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