10

The default pound sign is large and goes below the baseline.

I think it's rather ugly, and I'd like to shrink it. Other people have suggested using \texttt, but I use monospacing a lot in the document, and it would look like it's supposed to be highlighted as code if I monospaced the (#), which it's not. I also don't like the output of that either.

How can I shrink it to be as tall as a regular capital?

These are all the packages I'm using that affect font output:

\documentclass[oneside,11pt]{memoir}

\usepackage[T1]{fontenc}    
\usepackage{lmodern}        
\usepackage{inconsolata}    % preferred monospaced font 
\begin{document}
X \# \texttt{\#} X % "X" to denote size of capital letters
\end{document}
  • 2
    Pound sign? # is a hash-tag ;-) Welcome to TeX.SX! Your code does not reveal very much. Which command do use to generate a 'pound' sign? Do you really mean £? –  Jul 22 '15 at 19:51
  • May be with the monospaced light font? – Manuel Jul 22 '15 at 19:53
  • Alright: Just learned, that # is called pound sign in the US –  Jul 22 '15 at 19:55
  • @clemens: Yope, just learned ;-) –  Jul 22 '15 at 19:56
  • 2
    I don't understand this sentence: »people have suggested using \texttt, but I use monospacing a lot in the document, and it would stand out«. How would \texttt{\#} stand out in monospaced font? – cgnieder Jul 22 '15 at 20:00
  • 5
    @ChristianHupfer and clemens - both of you are right, to some extent. Excerpting from the wikipedia entry on Number Sign, #: ... The term number sign is most commonly used when the symbol is used before a number. In the United States, it is sometimes known as the pound sign (particularly in the context of its use on telephone keypads), and has been traditionally used in the food industry as an abbreviation for pounds avoirdupois. Outside of North America the symbol is called hash and the corresponding telephone key is called the "hash key" ... – Mico Jul 22 '15 at 20:00
  • @clemens - I actually don't like the Wikipedia entry for "Pound Sign". In the US and Canada, the term "hash" or "hashtag" is in very common use for # -- no doubt because of Twitter. The term "pound" to denote # is still used by the phone companies, for sure. – Mico Jul 22 '15 at 20:06
  • @clemens: In Physics or Maths # is often an abbreviation for number of..., say # cars –  Jul 22 '15 at 20:07
  • I use it for cardinality: \#\{a,b,c\} – Sigur Jul 22 '15 at 20:10
  • 1
    @Sigur Another user for cardinality :) but I think we should keep this discussion on-topic. OP, if your question really is about shrinking the symbol to the height of a capital, can you edit the title to say so more clearly? Just taking this question at face-value (i.e. only the title) a 'better-looking' symbol is very much opinion-based. – Sean Allred Jul 22 '15 at 20:12
  • 1
    @ChristianHupfer I disagree: the question is not in the least ambiguous in this respect: the title uses the symbol! (BTW: it is definitely not called hashtag: a hashtag is the word that starts with a #.) – cgnieder Jul 22 '15 at 20:17
  • This is a near-duplicate of http://tex.stackexchange.com/questions/236792/how-to-write-a-nice-symbol/236814#236814. – Jason Zentz Jul 22 '15 at 20:52
  • @clemens I mean I use monospacing in multiple places in the document, and so using monospacing for the pound sign would look like it's supposed to be called out as a piece of code, which it's not. I'll edit the question. – Azor Ahai -him- Jul 22 '15 at 21:04
  • Anyway, to me, it will always mean 'contradiction'. – cfr Jul 22 '15 at 23:57
  • 1
    I believe a hashtag refers to this symbol plus an alphanumeric string. The symbol alone is a hash character. I prefer octothorpe. – Matthew Leingang Jul 23 '15 at 00:00
  • @cfr How would calling it a dollar sign help? $ is unambiguously a dollar sign. – Azor Ahai -him- Jul 23 '15 at 17:46
  • @PressTilty Indeed. As £ is unambiguously a pound sign. – cfr Jul 23 '15 at 17:54
  • 1
    @cfr Oh. Yes, sarcasm in text. Why don't we have a way to typeset that? – Azor Ahai -him- Jul 23 '15 at 21:17
  • @PressTilty It really is a significant oversight in the design of electronic media. I can only assume that the designers lacked a sense of the absurd. – cfr Jul 23 '15 at 21:21

2 Answers2

9

As Latin Modern seems to be your preferred font family, the definition of \mypound used in the example below may be what you're looking for.

enter image description here

\documentclass[oneside,11pt]{memoir}
\usepackage[T1]{fontenc}    
\usepackage{lmodern}        
\usepackage{graphicx} % for \scalebox and \raisebox macros
\newcommand\mypound{\scalebox{0.8}{\raisebox{0.4ex}{\#}}}
\begin{document}
X\#X, X\mypound X
\end{document}

Addendum to address the OP's follow-up comment. The macros \scalebox and \raisebox are "fragile" (in the LaTeX sense of the word), and this fact gives rise to the error message you've encountered. A "robust" (again, using LaTeX jargon) version of the \mypound macro would be

\newcommand\mypound{\protect\scalebox{0.8}{\protect\raisebox{0.4ex}{\#}}}

Finally, if you want to be able to keep using \# as the directive that generates the (now resized) # symbol, you might use the following definition:

\renewcommand\#{\protect\scalebox{0.8}{\protect\raisebox{0.4ex}{\char"0023}}}

If you take this approach and find you also need to typeset the "original" pound/hash symbol, you would need to input it as \char"0023.

Mico
  • 506,678
  • 1
    May be \resizebox is the appropiate here? – Manuel Jul 22 '15 at 20:39
  • @Manuel - I did think about the method you're suggesting. I concluded its parameters are every bit as font dependent as is \scalebox. Moreover, with either \resizebox or \scalebox, the result is likely to look somewhat spindly, and maybe even anorexic. My own preferred method, really, would be to go out and find a hash/pound symbol among the multitude of fonts in existence, and perform no scaling at all. – Mico Jul 22 '15 at 20:46
  • 1
    To avoid manual calculations \resizebox{!}{\fontcharht\font`X}{\raisebox{\depth}{\#}} (the \raisebox bit is because I don't know how to remove the depth of the inside before passing it to \resizebox). But gives practically the same as your solution. – Manuel Jul 22 '15 at 21:01
  • 4
    @Manuel - Thanks for providing this additional solution. It may certainly seem advantageous to have a method that aligns the resized # character exactly with the baseline and the caps line (after all, that's what the OP said he/she wants!), while fully eliminating manual calculations. The downside, in my view, is that the resulting symbol will actually not "look right" because it has (by design!) no undershoot below the baseline and no overshoot above the caps line. If you look closely at the output of my solution, you'll see there's both some undershoot and overshoot. That was deliberate. – Mico Jul 22 '15 at 21:12
  • 1
    When I attempt to use this a subsection header, it gives me argument of \@xtrplargoom has an extra } Will this work in section headers? – Azor Ahai -him- Jul 22 '15 at 23:21
  • 1
    @PressTilty - Sometimes -- actually, quite often (sigh) -- the meaning of TeX and LaTeX error messages is nearly unfathomable. In the present case, the source of error message is the fact that the macros \scalebox and \raisebox are "fragile", in LaTeX sense of the word. I'll post an addendum that shows how the macro \mypound may be made "robust" and can thus be used in the arguments of macros such as \subsection. – Mico Jul 22 '15 at 23:44
5

Here is a minor adjustment to the placement and size of \#:

\usepackage{adjustbox}
\let\oldhash\#%
\DeclareRobustCommand{\#}{\adjustbox{valign=B,totalheight=.57\baselineskip}{\oldhash}}%

adjustbox's valign=B ensures that the bottom of the box lies on the baseline, while totalheight=.57\baselineskip ensures it is about the size of a capital letter in the current font. Of course, one could make perfect adjustments, but it doesn't really make that much of a difference.

enter image description here

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern,adjustbox}

\begin{document}

\noindent
\begin{minipage}[t]{.5\textwidth}
  \tiny abc \# ABC

  \footnotesize abc \# ABC

  \small abc \# ABC

  \normalsize abc \# ABC

  \large abc \# ABC

  \Large abc \# ABC

  \LARGE abc \# ABC

  \huge abc \# ABC

  \Huge abc \# ABC
\end{minipage}%
\begin{minipage}[t]{.5\textwidth}
  \let\oldhash\#%
  \DeclareRobustCommand{\#}{\adjustbox{valign=B,totalheight=.57\baselineskip}{\oldhash}}%
  \tiny abc \# ABC

  \footnotesize abc \# ABC

  \small abc \# ABC

  \normalsize abc \# ABC

  \large abc \# ABC

  \Large abc \# ABC

  \LARGE abc \# ABC

  \huge abc \# ABC

  \Huge abc \# ABC
\end{minipage}%
\end{document}

The command is made robust to avoid premature expansion in certain contexts (like section headings, which includes writing to file).

Werner
  • 603,163
  • wouldn't it be more exact to use \ht (or the latex analog) to actually determine the height of a capital? in this implementation, i think the height could vary wildly if line-spacing is changed. – Sean Allred Jul 22 '15 at 20:18
  • 2
    (also, i don't think you need those {} after each \#.) – Sean Allred Jul 22 '15 at 20:18