How to make the correct hash-symbol in C Sharp (C#)
Like egreg said earlier in his comment, use \newcommand{\textsharp}{$\sharp$}
The hash symbol was used out of necessity since ASCII did not contain a sharp symbol, but it was intended as a sharp note symbol as the language name denotes.
Addendum: You could always use $^\sharp$
for superscript.
Since Computer Modern Roman does not have a fitting hash symbol, we need to look somewhere else. I experimented with several popular fonts and found that the hash symbol from Liberation Serif does not stand out, has approximately the same brush width and isn't too wide.
Unfortunately, as Liberation Serif is a TrueType font, it can't be readily used with pdfTeX. Below is the code to use it with XeTeX/LuaTeX.
\documentclass{article}
\usepackage{fontspec}
\newfontface\lserif{Liberation Serif}
\newcommand{\Csh}{C{\lserif\#}}
\begin{document}
Some text \Csh{} some text.
\end{document}
Workaround for pdfTeX
Process this file with XeTeX/LuaTeX and save the result as hash-symbol.pdf
:
\documentclass[border=0pt]{standalone}
\usepackage{fontspec}
\begin{document}% I get extra space without this comment
\fontspec{Liberation Serif}\#
\end{document}
Then use this code to include the symbol with pdfTeX:
\documentclass{article}
\usepackage{graphicx}
\newcommand{\Csh}{C\includegraphics{hash-symbol}}
\begin{document}
Some text \Csh{} some text.
\end{document}
The positioning of the symbol might be slightly off, use \kern
and \raisebox
to fine-tune. Also note that this will only work for one font size; to remedy this, \scalebox
might be useful (manual).
You might do with
\documentclass{article}
\usepackage{graphicx}
\newcommand{\Csharp}{%
{\settoheight{\dimen0}{C}C\kern-.05em \resizebox{!}{\dimen0}{\raisebox{\depth}{\#}}}}
\begin{document}
\Huge\Csharp
\end{document}
Here's the result; the second line has \fontseries{b}\selectfont\#
, but the strokes seem to be too heavy:
If you prefer to use the music sharp symbol, it might be
\newcommand{\Csharp}{%
{\settoheight{\dimen0}{C}C\kern-.05em \resizebox{!}{\dimen0}{\raisebox{\depth}{$\sharp$}}}}