How to make the correct hash-symbol in C Sharp (C#)
up vote
52
down vote
favorite
I want to make C#
look nice in my book, but with the following:
C#
it looks like this:
When it should look more like this:
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:
symbols
|
show 10 more comments
up vote
52
down vote
favorite
I want to make C#
look nice in my book, but with the following:
C#
it looks like this:
When it should look more like this:
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:
symbols
9
Usetexttt{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 usetexttt{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
|
show 10 more comments
up vote
52
down vote
favorite
up vote
52
down vote
favorite
I want to make C#
look nice in my book, but with the following:
C#
it looks like this:
When it should look more like this:
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:
symbols
I want to make C#
look nice in my book, but with the following:
C#
it looks like this:
When it should look more like this:
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:
symbols
symbols
edited Feb 14 '12 at 13:18
asked Feb 14 '12 at 13:00
Filip Ekberg
1,10341522
1,10341522
9
Usetexttt{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 usetexttt{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
|
show 10 more comments
9
Usetexttt{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 usetexttt{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
|
show 10 more comments
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.
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}
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).
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
|
show 12 more comments
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.
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
add a comment |
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:
If you prefer to use the music sharp symbol, it might be
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}
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
add a comment |
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
.
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}
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
add a comment |
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.
1
Copying is somewhat possible: overlay the drawing on a zero-sized white#
.
– Andrey Vihrov
Feb 14 '12 at 16:35
add a comment |
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:
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}
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 throughpdflatex
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
add a comment |
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:
1
You can get a better-matched sharp symbol in Libertine if you addusepackage[libertine]{newtxmath}
and then use$sharp$
.
– musarithmia
Jun 23 '16 at 17:11
add a comment |
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.
add a comment |
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}
The even simpler Cscalerel*{#}{X}
typesets as
add a comment |
up vote
0
down vote
You can try Cverb|#|
, if this form suits your purpose.
New contributor
Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
– Kurt
2 hours ago
add a comment |
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)?
add a comment |
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.
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}
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).
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
|
show 12 more comments
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.
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}
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).
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
|
show 12 more comments
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.
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}
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).
Since Computer Modern Roman does not have a fitting hash symbol, we need to look somewhere else. I experimented with several popular fonts and found that the hash symbol from Liberation Serif does not stand out, has approximately the same brush width and isn't too wide.
Unfortunately, as Liberation Serif is a TrueType font, it can't be readily used with pdfTeX. Below is the code to use it with XeTeX/LuaTeX.
documentclass{article}
usepackage{fontspec}
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}
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).
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
|
show 12 more comments
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
|
show 12 more comments
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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:
If you prefer to use the music sharp symbol, it might be
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}
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
add a comment |
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:
If you prefer to use the music sharp symbol, it might be
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}
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
add a comment |
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:
If you prefer to use the music sharp symbol, it might be
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}
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:
If you prefer to use the music sharp symbol, it might be
newcommand{Csharp}{%
{settoheight{dimen0}{C}Ckern-.05em resizebox{!}{dimen0}{raisebox{depth}{$sharp$}}}}
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
add a comment |
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
add a comment |
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
.
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}
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
add a comment |
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
.
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}
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
add a comment |
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
.
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}
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
.
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}
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
add a comment |
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
add a comment |
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.
1
Copying is somewhat possible: overlay the drawing on a zero-sized white#
.
– Andrey Vihrov
Feb 14 '12 at 16:35
add a comment |
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.
1
Copying is somewhat possible: overlay the drawing on a zero-sized white#
.
– Andrey Vihrov
Feb 14 '12 at 16:35
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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:
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}
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 throughpdflatex
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
add a comment |
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:
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}
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 throughpdflatex
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
add a comment |
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:
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}
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:
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}
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 throughpdflatex
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
add a comment |
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 throughpdflatex
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
add a comment |
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:
1
You can get a better-matched sharp symbol in Libertine if you addusepackage[libertine]{newtxmath}
and then use$sharp$
.
– musarithmia
Jun 23 '16 at 17:11
add a comment |
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:
1
You can get a better-matched sharp symbol in Libertine if you addusepackage[libertine]{newtxmath}
and then use$sharp$
.
– musarithmia
Jun 23 '16 at 17:11
add a comment |
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:
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:
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 addusepackage[libertine]{newtxmath}
and then use$sharp$
.
– musarithmia
Jun 23 '16 at 17:11
add a comment |
1
You can get a better-matched sharp symbol in Libertine if you addusepackage[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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jun 13 '12 at 9:00
Tarion
1514
1514
add a comment |
add a comment |
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}
The even simpler Cscalerel*{#}{X}
typesets as
add a comment |
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}
The even simpler Cscalerel*{#}{X}
typesets as
add a comment |
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}
The even simpler Cscalerel*{#}{X}
typesets as
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}
The even simpler Cscalerel*{#}{X}
typesets as
answered Jun 29 '17 at 13:10
Steven B. Segletes
152k9192399
152k9192399
add a comment |
add a comment |
up vote
0
down vote
You can try Cverb|#|
, if this form suits your purpose.
New contributor
Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
– Kurt
2 hours ago
add a comment |
up vote
0
down vote
You can try Cverb|#|
, if this form suits your purpose.
New contributor
Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
– Kurt
2 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
You can try Cverb|#|
, if this form suits your purpose.
New contributor
You can try Cverb|#|
, if this form suits your purpose.
New contributor
New contributor
answered 2 hours ago
Inc0gnito
1
1
New contributor
New contributor
Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
– Kurt
2 hours ago
add a comment |
Welcome to TeX.SE! Please do not only show code, show also the result. BTW: best woulb be to show a compilable code ...
– Kurt
2 hours 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
2 hours 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
2 hours ago
add a comment |
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)?
add a comment |
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)?
add a comment |
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)?
How about these?
defCSH{{Cnolinebreak[4]hspace{-.05em}raisebox{.4ex}{footnotesizebf #}}}
A direct variation of Prettiest way to typeset "C++" (cplusplus)?
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Jul 2 '16 at 22:31
Nestor Waldyd
10914
10914
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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