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}
20
  • 1
    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 £?
    – user31729
    Jul 22 '15 at 19:51
  • 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
  • 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. 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
8

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.

6
  • 1
    May be \resizebox is the appropiate here?
    – Manuel
    Jul 22 '15 at 20:39
  • 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? 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
4

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

2
  • 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. Jul 22 '15 at 20:18
  • 2
    (also, i don't think you need those {} after each \#.) Jul 22 '15 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.