# Comma should come in italic font inside equations

My tags are as follow:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{txfonts}
\begin{document}

Test \quad $a,b$\quad \textit{a, b}\quad a, b

\end{document}


In this, I need to get the comma character to be in italic font within both inline and display equations. Any suggestions?

• Why should it? I see no reason. – egreg Jul 11 '18 at 11:39
• You deserve my sympathy. ;-) – egreg Jul 11 '18 at 11:51
• @MadyYuvi you are allowed to say no, and point to more or less any published math work, which does not do that. – David Carlisle Jul 11 '18 at 11:56
• Honestly, would any reasonable person even notice, let alone care about, the difference? – David Richerby Jul 11 '18 at 12:56
• @ChrisH You may very well think this professor is completely unreasonable. I couldn’t possibly comment. – David Richerby Jul 11 '18 at 15:33

You can redeclare the comma in math mode.

## With newtx (to be preferred over txfonts)

\documentclass{article}

\makeatletter
\DeclareSymbolFont{italic}{\tx@enc}{\rmdefaultB}{m}{it}
\SetSymbolFont{italic}{bold}{\tx@enc}{\rmdefaultB}{\bold@wt}{it}
\DeclareSymbolFontAlphabet{\mathit}{italic}
\DeclareMathSymbol{,}{\mathpunct}{italic}{,}
\makeatother

\begin{document}

Test \quad $a,b$\quad \textit{a, b}\quad a, b

\end{document}


## With txfonts

\documentclass{article}
\usepackage{txfonts}

\DeclareSymbolFont{italic}{OT1}{txr}{m}{it}
\SetSymbolFont{italic}{bold}{OT1}{txr}{bx}{it}
\DeclareSymbolFontAlphabet{\mathit}{italic}
\DeclareMathSymbol{,}{\mathpunct}{italic}{,}

\begin{document}

Test \quad $a,b$\quad \textit{a, b}\quad a, b

\end{document}


## Some explanations

The newtxmath package defines a math alphabet

\DeclareMathAlphabet{\mathit}{\tx@enc}{\rmdefaultB}{m}{it}
\SetMathAlphabet{\mathit}{bold}{\tx@enc}{\rmdefaultB}{\bold@wt}{it}


but we want to borrow the comma from this font as a math symbol. So instead we declare a symbol font with the same parameters (encoding, family, weight and shape) and redeclare \mathit with \DeclareSymbolFontAlphabet. Then the declaration of the comma is straightforward.

Simply adding \textit{} around a comma will make the comma character italic in math mode. So:

$a\textit{,}b$

• thanks for your advise, it is any way to achieve this without doing the manual thing? – MadyYuvi Jul 11 '18 at 11:38
• Not that I know of. You could make a custom command for this but then you would still have to replace your commas by that custom command. At that point you would probably just save time by typing the comma and pressing Ctrl+I in your editor. – Flexo013 Jul 11 '18 at 11:41
• @Flexo013 You don't know what editor I'm using, so you don't know what ctrl+I will do... – David Richerby Jul 11 '18 at 12:55
• @DavidRicherby that is correct. You can simply find the equivalent shortcut for your editor of choice. I was merely providing a commonly used shortcut for italicizing text. – Flexo013 Jul 11 '18 at 13:19