How to make the correct hash-symbol in C Sharp (C#)











up vote
52
down vote

favorite
11












I want to make C# look nice in my book, but with the following:



C# it looks like this:



enter image description here



When it should look more like this:



enter image description here



For the second one, I used verbatim, but I don't want that and I've also used a macro like the following everywhere so it should be easy to replace:



defCsharp{C#}



Any suggestions on how I make this look correct?



Edit



I am writing a programming book, in the C# Language Specification, it looks like this:



enter image description here










share|improve this question




















  • 9




    Use texttt{C#} for your second picture. And you'll find this question useful: Prettiest way to typeset “C++”?
    – Leo Liu
    Feb 14 '12 at 13:03






  • 5




    If it's about music, newcommand{textsharp}{$sharp$}
    – egreg
    Feb 14 '12 at 13:07






  • 5




    Don't use texttt{C#}. 'C' must be set in the normal font.
    – Andrey Vihrov
    Feb 14 '12 at 13:24






  • 3




    My opinion is that you should not fiddle with the symbol placement, because it will disrupt the read flow. Instead you should find/create a good-looking hash symbol that will not stand out. While most popular fonts have such a symbol, Computer Modern Roman/Sans Serif, unfortunately, does not.
    – Andrey Vihrov
    Feb 14 '12 at 14:07








  • 4




    @FilipEkberg Actually, it should be a sharp symbol as in a musical sharp note, it was intended to be this way, the only reason for a hash symbol can be summed up in ASCII. I believe some modern books use the originally intended musical sharp character.
    – Ayman Elmasry
    Feb 14 '12 at 14:46

















up vote
52
down vote

favorite
11












I want to make C# look nice in my book, but with the following:



C# it looks like this:



enter image description here



When it should look more like this:



enter image description here



For the second one, I used verbatim, but I don't want that and I've also used a macro like the following everywhere so it should be easy to replace:



defCsharp{C#}



Any suggestions on how I make this look correct?



Edit



I am writing a programming book, in the C# Language Specification, it looks like this:



enter image description here










share|improve this question




















  • 9




    Use texttt{C#} for your second picture. And you'll find this question useful: Prettiest way to typeset “C++”?
    – Leo Liu
    Feb 14 '12 at 13:03






  • 5




    If it's about music, newcommand{textsharp}{$sharp$}
    – egreg
    Feb 14 '12 at 13:07






  • 5




    Don't use texttt{C#}. 'C' must be set in the normal font.
    – Andrey Vihrov
    Feb 14 '12 at 13:24






  • 3




    My opinion is that you should not fiddle with the symbol placement, because it will disrupt the read flow. Instead you should find/create a good-looking hash symbol that will not stand out. While most popular fonts have such a symbol, Computer Modern Roman/Sans Serif, unfortunately, does not.
    – Andrey Vihrov
    Feb 14 '12 at 14:07








  • 4




    @FilipEkberg Actually, it should be a sharp symbol as in a musical sharp note, it was intended to be this way, the only reason for a hash symbol can be summed up in ASCII. I believe some modern books use the originally intended musical sharp character.
    – Ayman Elmasry
    Feb 14 '12 at 14:46















up vote
52
down vote

favorite
11









up vote
52
down vote

favorite
11






11





I want to make C# look nice in my book, but with the following:



C# it looks like this:



enter image description here



When it should look more like this:



enter image description here



For the second one, I used verbatim, but I don't want that and I've also used a macro like the following everywhere so it should be easy to replace:



defCsharp{C#}



Any suggestions on how I make this look correct?



Edit



I am writing a programming book, in the C# Language Specification, it looks like this:



enter image description here










share|improve this question















I want to make C# look nice in my book, but with the following:



C# it looks like this:



enter image description here



When it should look more like this:



enter image description here



For the second one, I used verbatim, but I don't want that and I've also used a macro like the following everywhere so it should be easy to replace:



defCsharp{C#}



Any suggestions on how I make this look correct?



Edit



I am writing a programming book, in the C# Language Specification, it looks like this:



enter image description here







symbols






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 14 '12 at 13:18

























asked Feb 14 '12 at 13:00









Filip Ekberg

1,10341522




1,10341522








  • 9




    Use texttt{C#} for your second picture. And you'll find this question useful: Prettiest way to typeset “C++”?
    – Leo Liu
    Feb 14 '12 at 13:03






  • 5




    If it's about music, newcommand{textsharp}{$sharp$}
    – egreg
    Feb 14 '12 at 13:07






  • 5




    Don't use texttt{C#}. 'C' must be set in the normal font.
    – Andrey Vihrov
    Feb 14 '12 at 13:24






  • 3




    My opinion is that you should not fiddle with the symbol placement, because it will disrupt the read flow. Instead you should find/create a good-looking hash symbol that will not stand out. While most popular fonts have such a symbol, Computer Modern Roman/Sans Serif, unfortunately, does not.
    – Andrey Vihrov
    Feb 14 '12 at 14:07








  • 4




    @FilipEkberg Actually, it should be a sharp symbol as in a musical sharp note, it was intended to be this way, the only reason for a hash symbol can be summed up in ASCII. I believe some modern books use the originally intended musical sharp character.
    – Ayman Elmasry
    Feb 14 '12 at 14:46
















  • 9




    Use texttt{C#} for your second picture. And you'll find this question useful: Prettiest way to typeset “C++”?
    – Leo Liu
    Feb 14 '12 at 13:03






  • 5




    If it's about music, newcommand{textsharp}{$sharp$}
    – egreg
    Feb 14 '12 at 13:07






  • 5




    Don't use texttt{C#}. 'C' must be set in the normal font.
    – Andrey Vihrov
    Feb 14 '12 at 13:24






  • 3




    My opinion is that you should not fiddle with the symbol placement, because it will disrupt the read flow. Instead you should find/create a good-looking hash symbol that will not stand out. While most popular fonts have such a symbol, Computer Modern Roman/Sans Serif, unfortunately, does not.
    – Andrey Vihrov
    Feb 14 '12 at 14:07








  • 4




    @FilipEkberg Actually, it should be a sharp symbol as in a musical sharp note, it was intended to be this way, the only reason for a hash symbol can be summed up in ASCII. I believe some modern books use the originally intended musical sharp character.
    – Ayman Elmasry
    Feb 14 '12 at 14:46










9




9




Use texttt{C#} for your second picture. And you'll find this question useful: Prettiest way to typeset “C++”?
– Leo Liu
Feb 14 '12 at 13:03




Use texttt{C#} for your second picture. And you'll find this question useful: Prettiest way to typeset “C++”?
– Leo Liu
Feb 14 '12 at 13:03




5




5




If it's about music, newcommand{textsharp}{$sharp$}
– egreg
Feb 14 '12 at 13:07




If it's about music, newcommand{textsharp}{$sharp$}
– egreg
Feb 14 '12 at 13:07




5




5




Don't use texttt{C#}. 'C' must be set in the normal font.
– Andrey Vihrov
Feb 14 '12 at 13:24




Don't use texttt{C#}. 'C' must be set in the normal font.
– Andrey Vihrov
Feb 14 '12 at 13:24




3




3




My opinion is that you should not fiddle with the symbol placement, because it will disrupt the read flow. Instead you should find/create a good-looking hash symbol that will not stand out. While most popular fonts have such a symbol, Computer Modern Roman/Sans Serif, unfortunately, does not.
– Andrey Vihrov
Feb 14 '12 at 14:07






My opinion is that you should not fiddle with the symbol placement, because it will disrupt the read flow. Instead you should find/create a good-looking hash symbol that will not stand out. While most popular fonts have such a symbol, Computer Modern Roman/Sans Serif, unfortunately, does not.
– Andrey Vihrov
Feb 14 '12 at 14:07






4




4




@FilipEkberg Actually, it should be a sharp symbol as in a musical sharp note, it was intended to be this way, the only reason for a hash symbol can be summed up in ASCII. I believe some modern books use the originally intended musical sharp character.
– Ayman Elmasry
Feb 14 '12 at 14:46






@FilipEkberg Actually, it should be a sharp symbol as in a musical sharp note, it was intended to be this way, the only reason for a hash symbol can be summed up in ASCII. I believe some modern books use the originally intended musical sharp character.
– Ayman Elmasry
Feb 14 '12 at 14:46












11 Answers
11






active

oldest

votes

















up vote
22
down vote



accepted










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.



Result



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}

newfontfacelserif{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}{Cincludegraphics{hash-symbol}}

begin{document}

Some text Csh{} some text.

end{document}


enter image description here



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






share|improve this answer



















  • 1




    It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
    – Filip Ekberg
    Feb 14 '12 at 14:52






  • 2




    @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
    – Konrad Rudolph
    Feb 14 '12 at 15:30






  • 1




    @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
    – Filip Ekberg
    Feb 14 '12 at 17:09






  • 1




    @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
    – Konrad Rudolph
    Feb 14 '12 at 17:27






  • 4




    @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
    – kahen
    Feb 15 '12 at 3:41


















up vote
39
down vote













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.



enter image description here






share|improve this answer



















  • 16




    Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
    – Todd Lehman
    Feb 16 '12 at 3:22






  • 1




    Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
    – Blaisorblade
    Jun 6 '13 at 17:41


















up vote
20
down vote













You might do with



documentclass{article}
usepackage{graphicx}
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{#}}}}
begin{document}
HugeCsharp
end{document}


Here's the result; the second line has fontseries{b}selectfont#, but the strokes seem to be too heavy:



enter image description here



If you prefer to use the music sharp symbol, it might be



newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}


enter image description here






share|improve this answer



















  • 1




    When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
    – littleO
    Jun 28 '17 at 3:00






  • 2




    @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
    – egreg
    Jun 28 '17 at 7:51






  • 1




    Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
    – littleO
    Jun 28 '17 at 7:55




















up vote
5
down vote













Here’s a version using ooalign to combine an equal sign with two tightly kerned slashes. It works for all 10 standard sizes from tiny up to Huge.



examples



The Good




  • The line stroke widths are consistent and feel right (to me).


The Bad




  • As you can see from the code below, it’s rather a bit of a hack. I’m sure there are probably more elegant ways to do this. Perhaps someone can improve it and post a follow-up.

  • You may need to tweak the positioning parameters if you’re using non-CMR or non-LMR fonts.

  • The reason the implentation is so complicated is because the regular slash character is too tall for this, necessitating the use of a smaller sized slash in each case. Everything above footnotesize uses a smaller slash; the smallest three make do with their respective native slashes.


The Ugly




  • Because of calculation rounding issues, the display of this may not look quite right on screen; you may notice the // and the = appearing to be 1 pixel out of alignment in an on-screen PDF viewer at low dpi. It should be fine in print, however. This problem is common with many hand-composited symbols like this one.


Here’s the code with an (almost) MWE:



documentclass{article}

begin{document}

makeatletter
defCsharp@tiny{5}
defCsharp@scriptsize{7}
defCsharp@footnotesize{8}
defCsharp@small{9}
defCsharp@normalsize{10}
defCsharp@large{12}
defCsharp@Large{14.4}
defCsharp@LARGE{17.28}
defCsharp@huge{20.74}
defCsharp@Huge{24.88}
newcommand{Csharp}{%
mbox{%
C%
ooalign{%
noalign{%
ifxf@sizeCsharp@tinyvskip-1.11exfi%
ifxf@sizeCsharp@scriptsizevskip-1.11exfi%
ifxf@sizeCsharp@footnotesizevskip-1.07exfi%
ifxf@sizeCsharp@smallvskip-1.07exfi%
ifxf@sizeCsharp@normalsizevskip-1.07exfi%
ifxf@sizeCsharp@largevskip-1.07exfi%
ifxf@sizeCsharp@Largevskip-1.07exfi%
ifxf@sizeCsharp@LARGEvskip-1.07exfi%
ifxf@sizeCsharp@hugevskip-1.07exfi%
ifxf@sizeCsharp@Hugevskip-1.07exfi%
}%
hss{=}hsscr%
noalign{%
ifxf@sizeCsharp@tinyvskip-0exfi%
ifxf@sizeCsharp@scriptsizevskip-0exfi%
ifxf@sizeCsharp@footnotesizevskip-0exfi%
ifxf@sizeCsharp@smallvskip-.06exfi%
ifxf@sizeCsharp@normalsizevskip-.10exfi%
ifxf@sizeCsharp@largevskip-.10exfi%
ifxf@sizeCsharp@Largevskip-.10exfi%
ifxf@sizeCsharp@LARGEvskip-.10exfi%
ifxf@sizeCsharp@hugevskip-.10exfi%
ifxf@sizeCsharp@Hugevskip-.10exfi%
}%
hss{%
ifxf@sizeCsharp@tinytinyfi%
ifxf@sizeCsharp@scriptsizescriptsizefi%
ifxf@sizeCsharp@footnotesizefootnotesizefi%
ifxf@sizeCsharp@smallfootnotesizefi%
ifxf@sizeCsharp@normalsizefootnotesizefi%
ifxf@sizeCsharp@largenormalsizefi%
ifxf@sizeCsharp@Largelargefi%
ifxf@sizeCsharp@LARGELargefi%
ifxf@sizeCsharp@hugeLARGEfi%
ifxf@sizeCsharp@Hugehugefi%
{/}kern-.26em{/}%
}hsscr%
}%
}%
}
makeatother

emergencystretch=2em
narrowernarrowernarrowernarrowernarrowernarrowernarrower
noindentCsharp (pronounced ``see sharp'') is a multi-paradigm programming language
encompassing strong typing, imperative, declarative, functional, generic,
object-oriented (class-based), and component-oriented programming disciplines.
vskip 1em
noindenttinyCsharp,
scriptsizeCsharp,
footnotesizeCsharp,
smallCsharp,
normalsizeCsharpparvskip-.25em
noindentlargeCsharp,
LargeCsharp,
LARGECsharpparvskip-.25em
noindenthugeCsharp,
HugeCsharppar

end{document}





share|improve this answer

















  • 4




    Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
    – kahen
    Feb 16 '12 at 10:12




















up vote
4
down vote













Using TikZ it's possible to draw the desired symbol manually:



defCsharp{Ctikz[x=1em,y=baselineskip]%
draw (0.125,0.15) -- ++(0.15,0.5)%
(0.325,0.15) -- ++(0.15,0.5)%
(0.05,0.3) -- ++(0.45,0.0)%
(0.1,0.5) -- ++(0.45,0.0);}


This has some issues though. For example the symbol doesn't scale all that well with changing font size, but the difference between Large and normalsize isn't too bad. Additionally it's impossible to copy "C#" from the resulting PDF file into the clipboard which may or may not be an issue.






share|improve this answer

















  • 1




    Copying is somewhat possible: overlay the drawing on a zero-sized white #.
    – Andrey Vihrov
    Feb 14 '12 at 16:35




















up vote
4
down vote













Building on the accepted answer and looking at the C# language specification (a .docx...) I came up with this:



newcommand{csharp}{Cnolinebreak[4]raisebox{.6ex}{includegraphics[scale=.8]{hash-symbol}}}


Which looks like this:



1



Note that when using LuaLaTex you'll need to add RequirePackage{luatex85} to the top of the file that you use for generating the PDF due to compatibility issues with the standalone document class. Also note that the Liberation fonts can be found here: https://fedorahosted.org/liberation-fonts/



MWE:



RequirePackage{luatex85}
documentclass[border=0pt]{standalone}
usepackage{fontspec}
begin{document}% I get extra space without this comment
fontspec{Liberation Serif}#
end{document}





share|improve this answer



















  • 1




    Where do I get the hash-symbol image? Can you give a MWE?
    – littleO
    Jun 28 '17 at 3:09






  • 2




    Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
    – theseion
    Jun 29 '17 at 10:43


















up vote
4
down vote













If you use XeTeX and your font supports it, you can put the Unicode character directly into your source file, or use symbol{"266F}. With fonts such as Linux Libertine, this looks much nicer than sharp, which seems to use raw TeX rather than looking for a proper sharp character:



Screenshot of different methods of rendering C# using XeTeX






share|improve this answer



















  • 1




    You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
    – musarithmia
    Jun 23 '16 at 17:11


















up vote
3
down vote













For pfdtex I prefere:



documentclass{article}
usepackage{graphicx}
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{textbf{#}}}}}
begin{document}
HugeCsharp
end{document}


Similar to the above but with thick #, because the thin one does not fit to the C in my eyes.






share|improve this answer




























    up vote
    0
    down vote













    Here, I take a # and, in superscript mode, make it the same vertical footprint as ig.



    documentclass{article}
    usepackage{scalerel}
    newcommandmyhash{$^{scalerel*{#}{ig}}$}
    begin{document}
    Cmyhash
    end{document}


    enter image description here



    The even simpler Cscalerel*{#}{X} typesets as



    enter image description here






    share|improve this answer




























      up vote
      0
      down vote













      You can try Cverb|#|, if this form suits your purpose.






      share|improve this answer








      New contributor




      Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.


















      • Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
        – Kurt
        1 hour ago




















      up vote
      -1
      down vote













      How about these?



      defCSH{{Cnolinebreak[4]hspace{-.05em}raisebox{.4ex}{footnotesizebf #}}}



      A direct variation of Prettiest way to typeset "C++" (cplusplus)?






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "85"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f44528%2fhow-to-make-the-correct-hash-symbol-in-c-sharp-c%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        11 Answers
        11






        active

        oldest

        votes








        11 Answers
        11






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        22
        down vote



        accepted










        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.



        Result



        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}

        newfontfacelserif{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}{Cincludegraphics{hash-symbol}}

        begin{document}

        Some text Csh{} some text.

        end{document}


        enter image description here



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






        share|improve this answer



















        • 1




          It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
          – Filip Ekberg
          Feb 14 '12 at 14:52






        • 2




          @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
          – Konrad Rudolph
          Feb 14 '12 at 15:30






        • 1




          @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
          – Filip Ekberg
          Feb 14 '12 at 17:09






        • 1




          @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
          – Konrad Rudolph
          Feb 14 '12 at 17:27






        • 4




          @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
          – kahen
          Feb 15 '12 at 3:41















        up vote
        22
        down vote



        accepted










        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.



        Result



        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}

        newfontfacelserif{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}{Cincludegraphics{hash-symbol}}

        begin{document}

        Some text Csh{} some text.

        end{document}


        enter image description here



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






        share|improve this answer



















        • 1




          It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
          – Filip Ekberg
          Feb 14 '12 at 14:52






        • 2




          @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
          – Konrad Rudolph
          Feb 14 '12 at 15:30






        • 1




          @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
          – Filip Ekberg
          Feb 14 '12 at 17:09






        • 1




          @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
          – Konrad Rudolph
          Feb 14 '12 at 17:27






        • 4




          @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
          – kahen
          Feb 15 '12 at 3:41













        up vote
        22
        down vote



        accepted







        up vote
        22
        down vote



        accepted






        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.



        Result



        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}

        newfontfacelserif{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}{Cincludegraphics{hash-symbol}}

        begin{document}

        Some text Csh{} some text.

        end{document}


        enter image description here



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






        share|improve this answer














        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.



        Result



        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}

        newfontfacelserif{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}{Cincludegraphics{hash-symbol}}

        begin{document}

        Some text Csh{} some text.

        end{document}


        enter image description here



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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 15 '12 at 8:29

























        answered Feb 14 '12 at 14:38









        Andrey Vihrov

        18.2k375101




        18.2k375101








        • 1




          It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
          – Filip Ekberg
          Feb 14 '12 at 14:52






        • 2




          @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
          – Konrad Rudolph
          Feb 14 '12 at 15:30






        • 1




          @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
          – Filip Ekberg
          Feb 14 '12 at 17:09






        • 1




          @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
          – Konrad Rudolph
          Feb 14 '12 at 17:27






        • 4




          @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
          – kahen
          Feb 15 '12 at 3:41














        • 1




          It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
          – Filip Ekberg
          Feb 14 '12 at 14:52






        • 2




          @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
          – Konrad Rudolph
          Feb 14 '12 at 15:30






        • 1




          @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
          – Filip Ekberg
          Feb 14 '12 at 17:09






        • 1




          @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
          – Konrad Rudolph
          Feb 14 '12 at 17:27






        • 4




          @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
          – kahen
          Feb 15 '12 at 3:41








        1




        1




        It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
        – Filip Ekberg
        Feb 14 '12 at 14:52




        It's a nice start, I need it to work with pdfText though, maybe someone else has some ideas on this too. Thanks!
        – Filip Ekberg
        Feb 14 '12 at 14:52




        2




        2




        @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
        – Konrad Rudolph
        Feb 14 '12 at 15:30




        @Filip You might consider switching anyway. While pdfTeX has served well, I would say that we might soon start to call it obsolete. Modern TeX implementations are simply superior in so many regards.
        – Konrad Rudolph
        Feb 14 '12 at 15:30




        1




        1




        @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
        – Filip Ekberg
        Feb 14 '12 at 17:09




        @KonradRudolph, pdflatex was what came with texlive/texniccenter. You're saying I should upgrade to something else?
        – Filip Ekberg
        Feb 14 '12 at 17:09




        1




        1




        @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
        – Konrad Rudolph
        Feb 14 '12 at 17:27




        @Filip TeXnicCenter is an editor (and a pretty crappy one at that, speak Unicode support). TeXLive and other distributions all ship with modern TeX renderers (XeTeX, LuaTeX, ConTeXt).
        – Konrad Rudolph
        Feb 14 '12 at 17:27




        4




        4




        @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
        – kahen
        Feb 15 '12 at 3:41




        @KonradRudolph: I wouldn't lump in ConTeXt with XeTeX and LuaTeX. ConTeXt is - like LaTeX - a macro package that sits on top of TeX while XeTeX and LuaTeX are implementations of TeX itself
        – kahen
        Feb 15 '12 at 3:41










        up vote
        39
        down vote













        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.



        enter image description here






        share|improve this answer



















        • 16




          Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
          – Todd Lehman
          Feb 16 '12 at 3:22






        • 1




          Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
          – Blaisorblade
          Jun 6 '13 at 17:41















        up vote
        39
        down vote













        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.



        enter image description here






        share|improve this answer



















        • 16




          Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
          – Todd Lehman
          Feb 16 '12 at 3:22






        • 1




          Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
          – Blaisorblade
          Jun 6 '13 at 17:41













        up vote
        39
        down vote










        up vote
        39
        down vote









        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.



        enter image description here






        share|improve this answer














        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.



        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 16 '12 at 10:05

























        answered Feb 14 '12 at 14:56









        Ayman Elmasry

        3,81993547




        3,81993547








        • 16




          Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
          – Todd Lehman
          Feb 16 '12 at 3:22






        • 1




          Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
          – Blaisorblade
          Jun 6 '13 at 17:41














        • 16




          Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
          – Todd Lehman
          Feb 16 '12 at 3:22






        • 1




          Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
          – Blaisorblade
          Jun 6 '13 at 17:41








        16




        16




        Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
        – Todd Lehman
        Feb 16 '12 at 3:22




        Yup! That’s why it’s called “C Sharp” and not “C Pound Sign” or “C Octothorpe”.
        – Todd Lehman
        Feb 16 '12 at 3:22




        1




        1




        Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
        – Blaisorblade
        Jun 6 '13 at 17:41




        Both the C# language specification and the LaTeX paper on C# I'm citing (Variance and Generalized Constraints for C♯ Generics) use a superscript, and $^sharp$ is the closest I can get.
        – Blaisorblade
        Jun 6 '13 at 17:41










        up vote
        20
        down vote













        You might do with



        documentclass{article}
        usepackage{graphicx}
        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{#}}}}
        begin{document}
        HugeCsharp
        end{document}


        Here's the result; the second line has fontseries{b}selectfont#, but the strokes seem to be too heavy:



        enter image description here



        If you prefer to use the music sharp symbol, it might be



        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}


        enter image description here






        share|improve this answer



















        • 1




          When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
          – littleO
          Jun 28 '17 at 3:00






        • 2




          @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
          – egreg
          Jun 28 '17 at 7:51






        • 1




          Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
          – littleO
          Jun 28 '17 at 7:55

















        up vote
        20
        down vote













        You might do with



        documentclass{article}
        usepackage{graphicx}
        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{#}}}}
        begin{document}
        HugeCsharp
        end{document}


        Here's the result; the second line has fontseries{b}selectfont#, but the strokes seem to be too heavy:



        enter image description here



        If you prefer to use the music sharp symbol, it might be



        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}


        enter image description here






        share|improve this answer



















        • 1




          When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
          – littleO
          Jun 28 '17 at 3:00






        • 2




          @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
          – egreg
          Jun 28 '17 at 7:51






        • 1




          Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
          – littleO
          Jun 28 '17 at 7:55















        up vote
        20
        down vote










        up vote
        20
        down vote









        You might do with



        documentclass{article}
        usepackage{graphicx}
        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{#}}}}
        begin{document}
        HugeCsharp
        end{document}


        Here's the result; the second line has fontseries{b}selectfont#, but the strokes seem to be too heavy:



        enter image description here



        If you prefer to use the music sharp symbol, it might be



        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}


        enter image description here






        share|improve this answer














        You might do with



        documentclass{article}
        usepackage{graphicx}
        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{#}}}}
        begin{document}
        HugeCsharp
        end{document}


        Here's the result; the second line has fontseries{b}selectfont#, but the strokes seem to be too heavy:



        enter image description here



        If you prefer to use the music sharp symbol, it might be



        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 14 '12 at 15:00

























        answered Feb 14 '12 at 14:53









        egreg

        703k8618753154




        703k8618753154








        • 1




          When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
          – littleO
          Jun 28 '17 at 3:00






        • 2




          @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
          – egreg
          Jun 28 '17 at 7:51






        • 1




          Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
          – littleO
          Jun 28 '17 at 7:55
















        • 1




          When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
          – littleO
          Jun 28 '17 at 3:00






        • 2




          @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
          – egreg
          Jun 28 '17 at 7:51






        • 1




          Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
          – littleO
          Jun 28 '17 at 7:55










        1




        1




        When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
        – littleO
        Jun 28 '17 at 3:00




        When I try this, I find that I have to manually insert a space by typing , after Csharp. The result doesn't look quite right. Could you modify your MWE to use Csharp in the middle of a sentence?
        – littleO
        Jun 28 '17 at 3:00




        2




        2




        @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
        – egreg
        Jun 28 '17 at 7:51




        @littleO Like every LaTeX command, it ”eats“ spaces after it. Use ”backslash space“ or {}
        – egreg
        Jun 28 '17 at 7:51




        1




        1




        Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
        – littleO
        Jun 28 '17 at 7:55






        Oh ok, thank you. I actually didn't realize I could just use "backslash space" to make a smaller space than I get with ,. This answer was really useful to me!
        – littleO
        Jun 28 '17 at 7:55












        up vote
        5
        down vote













        Here’s a version using ooalign to combine an equal sign with two tightly kerned slashes. It works for all 10 standard sizes from tiny up to Huge.



        examples



        The Good




        • The line stroke widths are consistent and feel right (to me).


        The Bad




        • As you can see from the code below, it’s rather a bit of a hack. I’m sure there are probably more elegant ways to do this. Perhaps someone can improve it and post a follow-up.

        • You may need to tweak the positioning parameters if you’re using non-CMR or non-LMR fonts.

        • The reason the implentation is so complicated is because the regular slash character is too tall for this, necessitating the use of a smaller sized slash in each case. Everything above footnotesize uses a smaller slash; the smallest three make do with their respective native slashes.


        The Ugly




        • Because of calculation rounding issues, the display of this may not look quite right on screen; you may notice the // and the = appearing to be 1 pixel out of alignment in an on-screen PDF viewer at low dpi. It should be fine in print, however. This problem is common with many hand-composited symbols like this one.


        Here’s the code with an (almost) MWE:



        documentclass{article}

        begin{document}

        makeatletter
        defCsharp@tiny{5}
        defCsharp@scriptsize{7}
        defCsharp@footnotesize{8}
        defCsharp@small{9}
        defCsharp@normalsize{10}
        defCsharp@large{12}
        defCsharp@Large{14.4}
        defCsharp@LARGE{17.28}
        defCsharp@huge{20.74}
        defCsharp@Huge{24.88}
        newcommand{Csharp}{%
        mbox{%
        C%
        ooalign{%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-1.11exfi%
        ifxf@sizeCsharp@scriptsizevskip-1.11exfi%
        ifxf@sizeCsharp@footnotesizevskip-1.07exfi%
        ifxf@sizeCsharp@smallvskip-1.07exfi%
        ifxf@sizeCsharp@normalsizevskip-1.07exfi%
        ifxf@sizeCsharp@largevskip-1.07exfi%
        ifxf@sizeCsharp@Largevskip-1.07exfi%
        ifxf@sizeCsharp@LARGEvskip-1.07exfi%
        ifxf@sizeCsharp@hugevskip-1.07exfi%
        ifxf@sizeCsharp@Hugevskip-1.07exfi%
        }%
        hss{=}hsscr%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-0exfi%
        ifxf@sizeCsharp@scriptsizevskip-0exfi%
        ifxf@sizeCsharp@footnotesizevskip-0exfi%
        ifxf@sizeCsharp@smallvskip-.06exfi%
        ifxf@sizeCsharp@normalsizevskip-.10exfi%
        ifxf@sizeCsharp@largevskip-.10exfi%
        ifxf@sizeCsharp@Largevskip-.10exfi%
        ifxf@sizeCsharp@LARGEvskip-.10exfi%
        ifxf@sizeCsharp@hugevskip-.10exfi%
        ifxf@sizeCsharp@Hugevskip-.10exfi%
        }%
        hss{%
        ifxf@sizeCsharp@tinytinyfi%
        ifxf@sizeCsharp@scriptsizescriptsizefi%
        ifxf@sizeCsharp@footnotesizefootnotesizefi%
        ifxf@sizeCsharp@smallfootnotesizefi%
        ifxf@sizeCsharp@normalsizefootnotesizefi%
        ifxf@sizeCsharp@largenormalsizefi%
        ifxf@sizeCsharp@Largelargefi%
        ifxf@sizeCsharp@LARGELargefi%
        ifxf@sizeCsharp@hugeLARGEfi%
        ifxf@sizeCsharp@Hugehugefi%
        {/}kern-.26em{/}%
        }hsscr%
        }%
        }%
        }
        makeatother

        emergencystretch=2em
        narrowernarrowernarrowernarrowernarrowernarrowernarrower
        noindentCsharp (pronounced ``see sharp'') is a multi-paradigm programming language
        encompassing strong typing, imperative, declarative, functional, generic,
        object-oriented (class-based), and component-oriented programming disciplines.
        vskip 1em
        noindenttinyCsharp,
        scriptsizeCsharp,
        footnotesizeCsharp,
        smallCsharp,
        normalsizeCsharpparvskip-.25em
        noindentlargeCsharp,
        LargeCsharp,
        LARGECsharpparvskip-.25em
        noindenthugeCsharp,
        HugeCsharppar

        end{document}





        share|improve this answer

















        • 4




          Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
          – kahen
          Feb 16 '12 at 10:12

















        up vote
        5
        down vote













        Here’s a version using ooalign to combine an equal sign with two tightly kerned slashes. It works for all 10 standard sizes from tiny up to Huge.



        examples



        The Good




        • The line stroke widths are consistent and feel right (to me).


        The Bad




        • As you can see from the code below, it’s rather a bit of a hack. I’m sure there are probably more elegant ways to do this. Perhaps someone can improve it and post a follow-up.

        • You may need to tweak the positioning parameters if you’re using non-CMR or non-LMR fonts.

        • The reason the implentation is so complicated is because the regular slash character is too tall for this, necessitating the use of a smaller sized slash in each case. Everything above footnotesize uses a smaller slash; the smallest three make do with their respective native slashes.


        The Ugly




        • Because of calculation rounding issues, the display of this may not look quite right on screen; you may notice the // and the = appearing to be 1 pixel out of alignment in an on-screen PDF viewer at low dpi. It should be fine in print, however. This problem is common with many hand-composited symbols like this one.


        Here’s the code with an (almost) MWE:



        documentclass{article}

        begin{document}

        makeatletter
        defCsharp@tiny{5}
        defCsharp@scriptsize{7}
        defCsharp@footnotesize{8}
        defCsharp@small{9}
        defCsharp@normalsize{10}
        defCsharp@large{12}
        defCsharp@Large{14.4}
        defCsharp@LARGE{17.28}
        defCsharp@huge{20.74}
        defCsharp@Huge{24.88}
        newcommand{Csharp}{%
        mbox{%
        C%
        ooalign{%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-1.11exfi%
        ifxf@sizeCsharp@scriptsizevskip-1.11exfi%
        ifxf@sizeCsharp@footnotesizevskip-1.07exfi%
        ifxf@sizeCsharp@smallvskip-1.07exfi%
        ifxf@sizeCsharp@normalsizevskip-1.07exfi%
        ifxf@sizeCsharp@largevskip-1.07exfi%
        ifxf@sizeCsharp@Largevskip-1.07exfi%
        ifxf@sizeCsharp@LARGEvskip-1.07exfi%
        ifxf@sizeCsharp@hugevskip-1.07exfi%
        ifxf@sizeCsharp@Hugevskip-1.07exfi%
        }%
        hss{=}hsscr%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-0exfi%
        ifxf@sizeCsharp@scriptsizevskip-0exfi%
        ifxf@sizeCsharp@footnotesizevskip-0exfi%
        ifxf@sizeCsharp@smallvskip-.06exfi%
        ifxf@sizeCsharp@normalsizevskip-.10exfi%
        ifxf@sizeCsharp@largevskip-.10exfi%
        ifxf@sizeCsharp@Largevskip-.10exfi%
        ifxf@sizeCsharp@LARGEvskip-.10exfi%
        ifxf@sizeCsharp@hugevskip-.10exfi%
        ifxf@sizeCsharp@Hugevskip-.10exfi%
        }%
        hss{%
        ifxf@sizeCsharp@tinytinyfi%
        ifxf@sizeCsharp@scriptsizescriptsizefi%
        ifxf@sizeCsharp@footnotesizefootnotesizefi%
        ifxf@sizeCsharp@smallfootnotesizefi%
        ifxf@sizeCsharp@normalsizefootnotesizefi%
        ifxf@sizeCsharp@largenormalsizefi%
        ifxf@sizeCsharp@Largelargefi%
        ifxf@sizeCsharp@LARGELargefi%
        ifxf@sizeCsharp@hugeLARGEfi%
        ifxf@sizeCsharp@Hugehugefi%
        {/}kern-.26em{/}%
        }hsscr%
        }%
        }%
        }
        makeatother

        emergencystretch=2em
        narrowernarrowernarrowernarrowernarrowernarrowernarrower
        noindentCsharp (pronounced ``see sharp'') is a multi-paradigm programming language
        encompassing strong typing, imperative, declarative, functional, generic,
        object-oriented (class-based), and component-oriented programming disciplines.
        vskip 1em
        noindenttinyCsharp,
        scriptsizeCsharp,
        footnotesizeCsharp,
        smallCsharp,
        normalsizeCsharpparvskip-.25em
        noindentlargeCsharp,
        LargeCsharp,
        LARGECsharpparvskip-.25em
        noindenthugeCsharp,
        HugeCsharppar

        end{document}





        share|improve this answer

















        • 4




          Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
          – kahen
          Feb 16 '12 at 10:12















        up vote
        5
        down vote










        up vote
        5
        down vote









        Here’s a version using ooalign to combine an equal sign with two tightly kerned slashes. It works for all 10 standard sizes from tiny up to Huge.



        examples



        The Good




        • The line stroke widths are consistent and feel right (to me).


        The Bad




        • As you can see from the code below, it’s rather a bit of a hack. I’m sure there are probably more elegant ways to do this. Perhaps someone can improve it and post a follow-up.

        • You may need to tweak the positioning parameters if you’re using non-CMR or non-LMR fonts.

        • The reason the implentation is so complicated is because the regular slash character is too tall for this, necessitating the use of a smaller sized slash in each case. Everything above footnotesize uses a smaller slash; the smallest three make do with their respective native slashes.


        The Ugly




        • Because of calculation rounding issues, the display of this may not look quite right on screen; you may notice the // and the = appearing to be 1 pixel out of alignment in an on-screen PDF viewer at low dpi. It should be fine in print, however. This problem is common with many hand-composited symbols like this one.


        Here’s the code with an (almost) MWE:



        documentclass{article}

        begin{document}

        makeatletter
        defCsharp@tiny{5}
        defCsharp@scriptsize{7}
        defCsharp@footnotesize{8}
        defCsharp@small{9}
        defCsharp@normalsize{10}
        defCsharp@large{12}
        defCsharp@Large{14.4}
        defCsharp@LARGE{17.28}
        defCsharp@huge{20.74}
        defCsharp@Huge{24.88}
        newcommand{Csharp}{%
        mbox{%
        C%
        ooalign{%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-1.11exfi%
        ifxf@sizeCsharp@scriptsizevskip-1.11exfi%
        ifxf@sizeCsharp@footnotesizevskip-1.07exfi%
        ifxf@sizeCsharp@smallvskip-1.07exfi%
        ifxf@sizeCsharp@normalsizevskip-1.07exfi%
        ifxf@sizeCsharp@largevskip-1.07exfi%
        ifxf@sizeCsharp@Largevskip-1.07exfi%
        ifxf@sizeCsharp@LARGEvskip-1.07exfi%
        ifxf@sizeCsharp@hugevskip-1.07exfi%
        ifxf@sizeCsharp@Hugevskip-1.07exfi%
        }%
        hss{=}hsscr%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-0exfi%
        ifxf@sizeCsharp@scriptsizevskip-0exfi%
        ifxf@sizeCsharp@footnotesizevskip-0exfi%
        ifxf@sizeCsharp@smallvskip-.06exfi%
        ifxf@sizeCsharp@normalsizevskip-.10exfi%
        ifxf@sizeCsharp@largevskip-.10exfi%
        ifxf@sizeCsharp@Largevskip-.10exfi%
        ifxf@sizeCsharp@LARGEvskip-.10exfi%
        ifxf@sizeCsharp@hugevskip-.10exfi%
        ifxf@sizeCsharp@Hugevskip-.10exfi%
        }%
        hss{%
        ifxf@sizeCsharp@tinytinyfi%
        ifxf@sizeCsharp@scriptsizescriptsizefi%
        ifxf@sizeCsharp@footnotesizefootnotesizefi%
        ifxf@sizeCsharp@smallfootnotesizefi%
        ifxf@sizeCsharp@normalsizefootnotesizefi%
        ifxf@sizeCsharp@largenormalsizefi%
        ifxf@sizeCsharp@Largelargefi%
        ifxf@sizeCsharp@LARGELargefi%
        ifxf@sizeCsharp@hugeLARGEfi%
        ifxf@sizeCsharp@Hugehugefi%
        {/}kern-.26em{/}%
        }hsscr%
        }%
        }%
        }
        makeatother

        emergencystretch=2em
        narrowernarrowernarrowernarrowernarrowernarrowernarrower
        noindentCsharp (pronounced ``see sharp'') is a multi-paradigm programming language
        encompassing strong typing, imperative, declarative, functional, generic,
        object-oriented (class-based), and component-oriented programming disciplines.
        vskip 1em
        noindenttinyCsharp,
        scriptsizeCsharp,
        footnotesizeCsharp,
        smallCsharp,
        normalsizeCsharpparvskip-.25em
        noindentlargeCsharp,
        LargeCsharp,
        LARGECsharpparvskip-.25em
        noindenthugeCsharp,
        HugeCsharppar

        end{document}





        share|improve this answer












        Here’s a version using ooalign to combine an equal sign with two tightly kerned slashes. It works for all 10 standard sizes from tiny up to Huge.



        examples



        The Good




        • The line stroke widths are consistent and feel right (to me).


        The Bad




        • As you can see from the code below, it’s rather a bit of a hack. I’m sure there are probably more elegant ways to do this. Perhaps someone can improve it and post a follow-up.

        • You may need to tweak the positioning parameters if you’re using non-CMR or non-LMR fonts.

        • The reason the implentation is so complicated is because the regular slash character is too tall for this, necessitating the use of a smaller sized slash in each case. Everything above footnotesize uses a smaller slash; the smallest three make do with their respective native slashes.


        The Ugly




        • Because of calculation rounding issues, the display of this may not look quite right on screen; you may notice the // and the = appearing to be 1 pixel out of alignment in an on-screen PDF viewer at low dpi. It should be fine in print, however. This problem is common with many hand-composited symbols like this one.


        Here’s the code with an (almost) MWE:



        documentclass{article}

        begin{document}

        makeatletter
        defCsharp@tiny{5}
        defCsharp@scriptsize{7}
        defCsharp@footnotesize{8}
        defCsharp@small{9}
        defCsharp@normalsize{10}
        defCsharp@large{12}
        defCsharp@Large{14.4}
        defCsharp@LARGE{17.28}
        defCsharp@huge{20.74}
        defCsharp@Huge{24.88}
        newcommand{Csharp}{%
        mbox{%
        C%
        ooalign{%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-1.11exfi%
        ifxf@sizeCsharp@scriptsizevskip-1.11exfi%
        ifxf@sizeCsharp@footnotesizevskip-1.07exfi%
        ifxf@sizeCsharp@smallvskip-1.07exfi%
        ifxf@sizeCsharp@normalsizevskip-1.07exfi%
        ifxf@sizeCsharp@largevskip-1.07exfi%
        ifxf@sizeCsharp@Largevskip-1.07exfi%
        ifxf@sizeCsharp@LARGEvskip-1.07exfi%
        ifxf@sizeCsharp@hugevskip-1.07exfi%
        ifxf@sizeCsharp@Hugevskip-1.07exfi%
        }%
        hss{=}hsscr%
        noalign{%
        ifxf@sizeCsharp@tinyvskip-0exfi%
        ifxf@sizeCsharp@scriptsizevskip-0exfi%
        ifxf@sizeCsharp@footnotesizevskip-0exfi%
        ifxf@sizeCsharp@smallvskip-.06exfi%
        ifxf@sizeCsharp@normalsizevskip-.10exfi%
        ifxf@sizeCsharp@largevskip-.10exfi%
        ifxf@sizeCsharp@Largevskip-.10exfi%
        ifxf@sizeCsharp@LARGEvskip-.10exfi%
        ifxf@sizeCsharp@hugevskip-.10exfi%
        ifxf@sizeCsharp@Hugevskip-.10exfi%
        }%
        hss{%
        ifxf@sizeCsharp@tinytinyfi%
        ifxf@sizeCsharp@scriptsizescriptsizefi%
        ifxf@sizeCsharp@footnotesizefootnotesizefi%
        ifxf@sizeCsharp@smallfootnotesizefi%
        ifxf@sizeCsharp@normalsizefootnotesizefi%
        ifxf@sizeCsharp@largenormalsizefi%
        ifxf@sizeCsharp@Largelargefi%
        ifxf@sizeCsharp@LARGELargefi%
        ifxf@sizeCsharp@hugeLARGEfi%
        ifxf@sizeCsharp@Hugehugefi%
        {/}kern-.26em{/}%
        }hsscr%
        }%
        }%
        }
        makeatother

        emergencystretch=2em
        narrowernarrowernarrowernarrowernarrowernarrowernarrower
        noindentCsharp (pronounced ``see sharp'') is a multi-paradigm programming language
        encompassing strong typing, imperative, declarative, functional, generic,
        object-oriented (class-based), and component-oriented programming disciplines.
        vskip 1em
        noindenttinyCsharp,
        scriptsizeCsharp,
        footnotesizeCsharp,
        smallCsharp,
        normalsizeCsharpparvskip-.25em
        noindentlargeCsharp,
        LargeCsharp,
        LARGECsharpparvskip-.25em
        noindenthugeCsharp,
        HugeCsharppar

        end{document}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 16 '12 at 4:44









        Todd Lehman

        9,69223450




        9,69223450








        • 4




          Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
          – kahen
          Feb 16 '12 at 10:12
















        • 4




          Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
          – kahen
          Feb 16 '12 at 10:12










        4




        4




        Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
        – kahen
        Feb 16 '12 at 10:12






        Defining those sizes seems pointless. The LaTeX kernel defines them as: @vpt, @viipt, @viiipt, @ixpt, @xpt, @xiipt, @xivpt, @xviipt, @xxpt, @xvpt and I don't think anything ever modifies them (because that would be crazy)
        – kahen
        Feb 16 '12 at 10:12












        up vote
        4
        down vote













        Using TikZ it's possible to draw the desired symbol manually:



        defCsharp{Ctikz[x=1em,y=baselineskip]%
        draw (0.125,0.15) -- ++(0.15,0.5)%
        (0.325,0.15) -- ++(0.15,0.5)%
        (0.05,0.3) -- ++(0.45,0.0)%
        (0.1,0.5) -- ++(0.45,0.0);}


        This has some issues though. For example the symbol doesn't scale all that well with changing font size, but the difference between Large and normalsize isn't too bad. Additionally it's impossible to copy "C#" from the resulting PDF file into the clipboard which may or may not be an issue.






        share|improve this answer

















        • 1




          Copying is somewhat possible: overlay the drawing on a zero-sized white #.
          – Andrey Vihrov
          Feb 14 '12 at 16:35

















        up vote
        4
        down vote













        Using TikZ it's possible to draw the desired symbol manually:



        defCsharp{Ctikz[x=1em,y=baselineskip]%
        draw (0.125,0.15) -- ++(0.15,0.5)%
        (0.325,0.15) -- ++(0.15,0.5)%
        (0.05,0.3) -- ++(0.45,0.0)%
        (0.1,0.5) -- ++(0.45,0.0);}


        This has some issues though. For example the symbol doesn't scale all that well with changing font size, but the difference between Large and normalsize isn't too bad. Additionally it's impossible to copy "C#" from the resulting PDF file into the clipboard which may or may not be an issue.






        share|improve this answer

















        • 1




          Copying is somewhat possible: overlay the drawing on a zero-sized white #.
          – Andrey Vihrov
          Feb 14 '12 at 16:35















        up vote
        4
        down vote










        up vote
        4
        down vote









        Using TikZ it's possible to draw the desired symbol manually:



        defCsharp{Ctikz[x=1em,y=baselineskip]%
        draw (0.125,0.15) -- ++(0.15,0.5)%
        (0.325,0.15) -- ++(0.15,0.5)%
        (0.05,0.3) -- ++(0.45,0.0)%
        (0.1,0.5) -- ++(0.45,0.0);}


        This has some issues though. For example the symbol doesn't scale all that well with changing font size, but the difference between Large and normalsize isn't too bad. Additionally it's impossible to copy "C#" from the resulting PDF file into the clipboard which may or may not be an issue.






        share|improve this answer












        Using TikZ it's possible to draw the desired symbol manually:



        defCsharp{Ctikz[x=1em,y=baselineskip]%
        draw (0.125,0.15) -- ++(0.15,0.5)%
        (0.325,0.15) -- ++(0.15,0.5)%
        (0.05,0.3) -- ++(0.45,0.0)%
        (0.1,0.5) -- ++(0.45,0.0);}


        This has some issues though. For example the symbol doesn't scale all that well with changing font size, but the difference between Large and normalsize isn't too bad. Additionally it's impossible to copy "C#" from the resulting PDF file into the clipboard which may or may not be an issue.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 14 '12 at 15:28









        kahen

        1,70311521




        1,70311521








        • 1




          Copying is somewhat possible: overlay the drawing on a zero-sized white #.
          – Andrey Vihrov
          Feb 14 '12 at 16:35
















        • 1




          Copying is somewhat possible: overlay the drawing on a zero-sized white #.
          – Andrey Vihrov
          Feb 14 '12 at 16:35










        1




        1




        Copying is somewhat possible: overlay the drawing on a zero-sized white #.
        – Andrey Vihrov
        Feb 14 '12 at 16:35






        Copying is somewhat possible: overlay the drawing on a zero-sized white #.
        – Andrey Vihrov
        Feb 14 '12 at 16:35












        up vote
        4
        down vote













        Building on the accepted answer and looking at the C# language specification (a .docx...) I came up with this:



        newcommand{csharp}{Cnolinebreak[4]raisebox{.6ex}{includegraphics[scale=.8]{hash-symbol}}}


        Which looks like this:



        1



        Note that when using LuaLaTex you'll need to add RequirePackage{luatex85} to the top of the file that you use for generating the PDF due to compatibility issues with the standalone document class. Also note that the Liberation fonts can be found here: https://fedorahosted.org/liberation-fonts/



        MWE:



        RequirePackage{luatex85}
        documentclass[border=0pt]{standalone}
        usepackage{fontspec}
        begin{document}% I get extra space without this comment
        fontspec{Liberation Serif}#
        end{document}





        share|improve this answer



















        • 1




          Where do I get the hash-symbol image? Can you give a MWE?
          – littleO
          Jun 28 '17 at 3:09






        • 2




          Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
          – theseion
          Jun 29 '17 at 10:43















        up vote
        4
        down vote













        Building on the accepted answer and looking at the C# language specification (a .docx...) I came up with this:



        newcommand{csharp}{Cnolinebreak[4]raisebox{.6ex}{includegraphics[scale=.8]{hash-symbol}}}


        Which looks like this:



        1



        Note that when using LuaLaTex you'll need to add RequirePackage{luatex85} to the top of the file that you use for generating the PDF due to compatibility issues with the standalone document class. Also note that the Liberation fonts can be found here: https://fedorahosted.org/liberation-fonts/



        MWE:



        RequirePackage{luatex85}
        documentclass[border=0pt]{standalone}
        usepackage{fontspec}
        begin{document}% I get extra space without this comment
        fontspec{Liberation Serif}#
        end{document}





        share|improve this answer



















        • 1




          Where do I get the hash-symbol image? Can you give a MWE?
          – littleO
          Jun 28 '17 at 3:09






        • 2




          Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
          – theseion
          Jun 29 '17 at 10:43













        up vote
        4
        down vote










        up vote
        4
        down vote









        Building on the accepted answer and looking at the C# language specification (a .docx...) I came up with this:



        newcommand{csharp}{Cnolinebreak[4]raisebox{.6ex}{includegraphics[scale=.8]{hash-symbol}}}


        Which looks like this:



        1



        Note that when using LuaLaTex you'll need to add RequirePackage{luatex85} to the top of the file that you use for generating the PDF due to compatibility issues with the standalone document class. Also note that the Liberation fonts can be found here: https://fedorahosted.org/liberation-fonts/



        MWE:



        RequirePackage{luatex85}
        documentclass[border=0pt]{standalone}
        usepackage{fontspec}
        begin{document}% I get extra space without this comment
        fontspec{Liberation Serif}#
        end{document}





        share|improve this answer














        Building on the accepted answer and looking at the C# language specification (a .docx...) I came up with this:



        newcommand{csharp}{Cnolinebreak[4]raisebox{.6ex}{includegraphics[scale=.8]{hash-symbol}}}


        Which looks like this:



        1



        Note that when using LuaLaTex you'll need to add RequirePackage{luatex85} to the top of the file that you use for generating the PDF due to compatibility issues with the standalone document class. Also note that the Liberation fonts can be found here: https://fedorahosted.org/liberation-fonts/



        MWE:



        RequirePackage{luatex85}
        documentclass[border=0pt]{standalone}
        usepackage{fontspec}
        begin{document}% I get extra space without this comment
        fontspec{Liberation Serif}#
        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 29 '17 at 10:42

























        answered Jun 23 '16 at 16:48









        theseion

        1586




        1586








        • 1




          Where do I get the hash-symbol image? Can you give a MWE?
          – littleO
          Jun 28 '17 at 3:09






        • 2




          Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
          – theseion
          Jun 29 '17 at 10:43














        • 1




          Where do I get the hash-symbol image? Can you give a MWE?
          – littleO
          Jun 28 '17 at 3:09






        • 2




          Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
          – theseion
          Jun 29 '17 at 10:43








        1




        1




        Where do I get the hash-symbol image? Can you give a MWE?
        – littleO
        Jun 28 '17 at 3:09




        Where do I get the hash-symbol image? Can you give a MWE?
        – littleO
        Jun 28 '17 at 3:09




        2




        2




        Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
        – theseion
        Jun 29 '17 at 10:43




        Added MWE. Run that through pdflatex and you should get the PDF. You can use PDF files as images, if that wasn't clear.
        – theseion
        Jun 29 '17 at 10:43










        up vote
        4
        down vote













        If you use XeTeX and your font supports it, you can put the Unicode character directly into your source file, or use symbol{"266F}. With fonts such as Linux Libertine, this looks much nicer than sharp, which seems to use raw TeX rather than looking for a proper sharp character:



        Screenshot of different methods of rendering C# using XeTeX






        share|improve this answer



















        • 1




          You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
          – musarithmia
          Jun 23 '16 at 17:11















        up vote
        4
        down vote













        If you use XeTeX and your font supports it, you can put the Unicode character directly into your source file, or use symbol{"266F}. With fonts such as Linux Libertine, this looks much nicer than sharp, which seems to use raw TeX rather than looking for a proper sharp character:



        Screenshot of different methods of rendering C# using XeTeX






        share|improve this answer



















        • 1




          You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
          – musarithmia
          Jun 23 '16 at 17:11













        up vote
        4
        down vote










        up vote
        4
        down vote









        If you use XeTeX and your font supports it, you can put the Unicode character directly into your source file, or use symbol{"266F}. With fonts such as Linux Libertine, this looks much nicer than sharp, which seems to use raw TeX rather than looking for a proper sharp character:



        Screenshot of different methods of rendering C# using XeTeX






        share|improve this answer














        If you use XeTeX and your font supports it, you can put the Unicode character directly into your source file, or use symbol{"266F}. With fonts such as Linux Libertine, this looks much nicer than sharp, which seems to use raw TeX rather than looking for a proper sharp character:



        Screenshot of different methods of rendering C# using XeTeX







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 29 '17 at 13:19

























        answered Mar 23 '14 at 8:45









        sjy

        28326




        28326








        • 1




          You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
          – musarithmia
          Jun 23 '16 at 17:11














        • 1




          You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
          – musarithmia
          Jun 23 '16 at 17:11








        1




        1




        You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
        – musarithmia
        Jun 23 '16 at 17:11




        You can get a better-matched sharp symbol in Libertine if you add usepackage[libertine]{newtxmath} and then use $sharp$.
        – musarithmia
        Jun 23 '16 at 17:11










        up vote
        3
        down vote













        For pfdtex I prefere:



        documentclass{article}
        usepackage{graphicx}
        newcommand{Csharp}{%
        {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{textbf{#}}}}}
        begin{document}
        HugeCsharp
        end{document}


        Similar to the above but with thick #, because the thin one does not fit to the C in my eyes.






        share|improve this answer

























          up vote
          3
          down vote













          For pfdtex I prefere:



          documentclass{article}
          usepackage{graphicx}
          newcommand{Csharp}{%
          {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{textbf{#}}}}}
          begin{document}
          HugeCsharp
          end{document}


          Similar to the above but with thick #, because the thin one does not fit to the C in my eyes.






          share|improve this answer























            up vote
            3
            down vote










            up vote
            3
            down vote









            For pfdtex I prefere:



            documentclass{article}
            usepackage{graphicx}
            newcommand{Csharp}{%
            {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{textbf{#}}}}}
            begin{document}
            HugeCsharp
            end{document}


            Similar to the above but with thick #, because the thin one does not fit to the C in my eyes.






            share|improve this answer












            For pfdtex I prefere:



            documentclass{article}
            usepackage{graphicx}
            newcommand{Csharp}{%
            {settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{textbf{#}}}}}
            begin{document}
            HugeCsharp
            end{document}


            Similar to the above but with thick #, because the thin one does not fit to the C in my eyes.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 13 '12 at 9:00









            Tarion

            1514




            1514






















                up vote
                0
                down vote













                Here, I take a # and, in superscript mode, make it the same vertical footprint as ig.



                documentclass{article}
                usepackage{scalerel}
                newcommandmyhash{$^{scalerel*{#}{ig}}$}
                begin{document}
                Cmyhash
                end{document}


                enter image description here



                The even simpler Cscalerel*{#}{X} typesets as



                enter image description here






                share|improve this answer

























                  up vote
                  0
                  down vote













                  Here, I take a # and, in superscript mode, make it the same vertical footprint as ig.



                  documentclass{article}
                  usepackage{scalerel}
                  newcommandmyhash{$^{scalerel*{#}{ig}}$}
                  begin{document}
                  Cmyhash
                  end{document}


                  enter image description here



                  The even simpler Cscalerel*{#}{X} typesets as



                  enter image description here






                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    Here, I take a # and, in superscript mode, make it the same vertical footprint as ig.



                    documentclass{article}
                    usepackage{scalerel}
                    newcommandmyhash{$^{scalerel*{#}{ig}}$}
                    begin{document}
                    Cmyhash
                    end{document}


                    enter image description here



                    The even simpler Cscalerel*{#}{X} typesets as



                    enter image description here






                    share|improve this answer












                    Here, I take a # and, in superscript mode, make it the same vertical footprint as ig.



                    documentclass{article}
                    usepackage{scalerel}
                    newcommandmyhash{$^{scalerel*{#}{ig}}$}
                    begin{document}
                    Cmyhash
                    end{document}


                    enter image description here



                    The even simpler Cscalerel*{#}{X} typesets as



                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 29 '17 at 13:10









                    Steven B. Segletes

                    152k9192399




                    152k9192399






















                        up vote
                        0
                        down vote













                        You can try Cverb|#|, if this form suits your purpose.






                        share|improve this answer








                        New contributor




                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.


















                        • Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
                          – Kurt
                          1 hour ago

















                        up vote
                        0
                        down vote













                        You can try Cverb|#|, if this form suits your purpose.






                        share|improve this answer








                        New contributor




                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.


















                        • Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
                          – Kurt
                          1 hour ago















                        up vote
                        0
                        down vote










                        up vote
                        0
                        down vote









                        You can try Cverb|#|, if this form suits your purpose.






                        share|improve this answer








                        New contributor




                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.









                        You can try Cverb|#|, if this form suits your purpose.







                        share|improve this answer








                        New contributor




                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.









                        share|improve this answer



                        share|improve this answer






                        New contributor




                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.









                        answered 1 hour ago









                        Inc0gnito

                        1




                        1




                        New contributor




                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





                        New contributor





                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.






                        Inc0gnito is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.












                        • Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
                          – Kurt
                          1 hour ago




















                        • Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
                          – Kurt
                          1 hour ago


















                        Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
                        – Kurt
                        1 hour ago






                        Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
                        – Kurt
                        1 hour ago












                        up vote
                        -1
                        down vote













                        How about these?



                        defCSH{{Cnolinebreak[4]hspace{-.05em}raisebox{.4ex}{footnotesizebf #}}}



                        A direct variation of Prettiest way to typeset "C++" (cplusplus)?






                        share|improve this answer



























                          up vote
                          -1
                          down vote













                          How about these?



                          defCSH{{Cnolinebreak[4]hspace{-.05em}raisebox{.4ex}{footnotesizebf #}}}



                          A direct variation of Prettiest way to typeset "C++" (cplusplus)?






                          share|improve this answer

























                            up vote
                            -1
                            down vote










                            up vote
                            -1
                            down vote









                            How about these?



                            defCSH{{Cnolinebreak[4]hspace{-.05em}raisebox{.4ex}{footnotesizebf #}}}



                            A direct variation of Prettiest way to typeset "C++" (cplusplus)?






                            share|improve this answer














                            How about these?



                            defCSH{{Cnolinebreak[4]hspace{-.05em}raisebox{.4ex}{footnotesizebf #}}}



                            A direct variation of Prettiest way to typeset "C++" (cplusplus)?







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Apr 13 '17 at 12:36









                            Community

                            1




                            1










                            answered Jul 2 '16 at 22:31









                            Nestor Waldyd

                            10914




                            10914






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f44528%2fhow-to-make-the-correct-hash-symbol-in-c-sharp-c%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Accessing regular linux commands in Huawei's Dopra Linux

                                Can't connect RFCOMM socket: Host is down

                                Kernel panic - not syncing: Fatal Exception in Interrupt