4

I want to write a Cis (C-sharp) with markup{}.

I am aware that there is a difference between the usual hashtag sign # (used in commenting code or on twitter) and the muscial sharp sign .

With the original sharp sign this code works well.

markup{C♯}

But I found out that it does not work with a hashtag even if it is escaped

markup{C#}
markup{C\#}

So why is that and how could this be solved without the original sharp sign?

3
  • 5
    Because # is LilyPond syntax to introduce Scheme code. Try \markup { "C#" }. Commented Apr 24, 2022 at 12:24
  • Why don't you just set up a keyboard layout that can type a ♯ rather than all this messing around? macOS you could do it with Ukelele [or even just a text replacement as I used here]. I'm sure Windows must have some sort of equivalent, even if it's the lumpy alt/unicode thing.
    – Tetsujin
    Commented Apr 24, 2022 at 15:36
  • 1
    Terminology nitpick: # is more usually known as the ‘hash’ sign*; hash_tag_ is the metadata tag beginning with a hash symbol. (* It's also sometimes called the ‘number’ sign — and in the US ‘pound’ sign, referring to the weight unit, but that's confusing in e.g. the UK where the pound sign is £ referring to the currency.)
    – gidds
    Commented Apr 24, 2022 at 21:52

2 Answers 2

6

Try:
\markup{C\sharp}

You might also like to make the symbol smaller and raise it up with \super, and and you'll probably want to concatenate the letter and symbol together with \concat; something like:

\markup{\concat{C\super\sharp}}

0

It is unclear to me what you want. You write

I am aware that there is a difference between the usual hashtag sign # (used in commenting code or on twitter) and the muscial sharp sign ♯.

And you state

With the original sharp sign this code works well. \markup{C♯}

Yet you appear to desire getting a hashtag sign instead of an accidental in a musical context. That makes little enough sense. Of course, LilyPond uses the hashtag sign for something different (introducing Scheme), and "it does not work with a hashtag even if it is escaped" is nonsensical in a language that does not use backslashes to escape special characters (other than in very specific in-string contexts).

It appears that you want \markup "C#" or in most contexts the simpler "C#" though it is unclear why.

1
  • 3
    What makes you say "you appear to desire getting a hashtag sign instead of an accidental"?
    – Richard
    Commented Apr 24, 2022 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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