2

I need a D-stroke in Euler, but it doesn't provide one. I've made a decent one with

\DeclareTextCommand{\DJ}{T1}{\raisebox{0.25ex}{-}\kern-0.4em D}

(taking from Why can't I get a D with stroke?), but this way I'm loosing Concrete's proper \DJ.

I know I could just define a different command \DJm instead, but I was wondering if it's possible to let LaTeX make the distinction between text and math and I wanted to ask for some references about \ProvideTextCommand and \DeclareTextCommand.


@Skillmon I've tried

\let\oldDJ\DJ
\DeclareTextCommand{\DJ}{T1}
{%
  \ifmmode%
    \raisebox{0.25ex}{-}\kern-0.4em D%
  \else%
    \oldDJ%
  \fi%
}

but I get TeX capacity exceeded, sorry [input stack size=5000]. I guess somehow my definition is recursive, but I can't figure out why.

  • 3
    You might test for math mode with \relax\ifmmode<code for math mode>\else<code for text mode>\fi. – Skillmon Aug 21 '17 at 18:15
  • 1
    I'd define \mathDJ – egreg Aug 21 '17 at 19:20
  • Hi @egreg, that's the kind of definition I meant with \DJm. It solves my problem but I was actually looking for something that wouldn't need a different command for math mode and normal text. Or some references, since I havent found anything googling for \ProvideTextCommand. – Arch Stanton Aug 21 '17 at 19:29
  • They are two different things, like \i and \imath – egreg Aug 21 '17 at 19:31
  • I know. I don't actually need Concrete's D-stroke since I will only use \DJ in math mode, that is in Euler. My question comes out of mere curiosity. :-) I've searched through interface3 and I haven't found any instance of "\ProvideTextCommand" or "\DeclareTextCommand". So I resorted to asking here. – Arch Stanton Aug 21 '17 at 19:35
2

I would define a \mathDJ command, but if you insist…

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{concrete}
\usepackage{amsmath}

\let\textDJ\DJ
\let\DJ\relax

\DeclareRobustCommand{\DJ}{%
  \ifmmode
    \mathDJ
  \else
    \textDJ
  \fi
}
\makeatletter
\newcommand{\mathDJ}{\text{\raisebox{0.25ex}{-}\kern-0.4em$\m@th D$}}
\makeatother

\begin{document}

\DJ{} and $\DJ_{\DJ}$

\end{document}

enter image description here

  • Thank you :-) I didn't think it had to be robust. Btw, if you or someone else can drop a link to some documentation for \ProvideTextCommand and \DeclareTextCommand, it'd be really helpful. – Arch Stanton Aug 21 '17 at 21:00
  • @ArchStanton You find something about them with texdoc source2e; the commands have been in LaTeX since the release of LaTeX2e – egreg Aug 21 '17 at 21:53
  • Just for completeness, the T1 encoding defines \DH and \DJ, plus the lowercase \dh and \dj. \DH and \DJ look identical in the OP's font, but \dh and \dj are different - \dh is like a "partial derivative with a slash" but \dh is an upright lowercase d with a slash. – alephzero Aug 22 '17 at 0:29

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.