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.

Is there any package with predefined macros for common programming languages' names? I mean, macros that help writing things like C++, C#, F# etc. in a nice way, the same way as for example \TeX? I have already written some of my own macros to do that but surely someone else has already thought about that and have prepared such useful macros in a package.

EDIT: Here are macros that I use myself. Might be useful for someone else.

\newcommand{\CPP}{C\nolinebreak[4]\hspace{-.05em}\raisebox{.3ex}{\small++}\xspace}
\newcommand{\CS}{C\nolinebreak[4]\hspace{-.05em}\raisebox{.2ex}{\small\#}\xspace}
\newcommand{\FS}{F\nolinebreak[4]\hspace{-.05em}\raisebox{.2ex}{\small\#}\xspace}
share|improve this question
1  
    
@tohecz thanks, though I knew about that discussion. In fact, the question came to my mind when I read that. –  AlefSin Jan 6 '13 at 22:23
    
Instead of using \nolinebreak, put the whole code in \hbox{...} –  tohecz Jan 6 '13 at 22:35
    
for TeX Logos there's hologo or metalogo –  bloodworks Jan 6 '13 at 22:40
1  
@tohecz Better \mbox, as \hbox doesn't start a paragraph if found in vertical mode. –  egreg Jan 8 '13 at 8:43

1 Answer 1

up vote 4 down vote accepted

As the answers to Prettiest way to typeset "C++"? show, there is no general consensus on how to typeset those fancy names. There's no package for them either.

Thus you're better using your definitions, probably written in a more context independent way; for instance your

\newcommand{\CPP}{C\nolinebreak[4]\hspace{-.05em}\raisebox{.3ex}{\small++}\xspace}

will give wrong results if used in a section title that's typeset at a larger size, because \small is hard coded:

enter image description here

You can do better with the relsize package or, as the scaling you require is not very big, with \scalebox:

\documentclass{article}
\usepackage{xspace,graphicx}
\newcommand{\CPP}{C\kern-.05em \raisebox{.3ex}{\scalebox{.9}{++}}\xspace}

\begin{document}

{\Large\texttt{\string\Large} size: \CPP\par}

\texttt{normal} size: \CPP\par

{\small\texttt{\string\small} size: \CPP\par}

\end{document}

As you can see in the following image, the font size is respected.

enter image description here

Using \kern-.05em instead of \hspace{-.05em} ensures that no break point is inserted between the C and the two plus signs. Alternatively

\newcommand{\CPP}{\mbox{C\hspace{-.05em}\raisebox{.3ex}{\scalebox{.9}{++}}}\xspace}

will do the same.

You can do similarly for \CS and \FS

share|improve this answer
    
Thanks for your answer. Yes, I also realized that there is no standard way to typeset the names for these languages. I liked your solution as mine was definitely broken. –  AlefSin Jan 8 '13 at 11:13

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.