So, I know there are a lot of posts about this already, with answers like \textasciitilde, \texttildelow and $\sim$ and they all seam to work in their own way. But what I've found is that they look like tilde when typeset, but when you highlight the character, copy it and paste it into a terminal window, it's a completely different character.

I've found that \texttildelow is the only command that creates an "actual" tilde-character, when copied and pasted into a terminal. However, it is printed very low in the pdf when used, and it looks like something else.

I need help managing all these ways to type tilde. I want to type tilde in both verbatim text and in normal text mode. What I would like is for the characters to look like a normal tilde when typeset, and also be the "real" tilde when copied into the terminal window. This is to simplify the process of using the commands I write. I don't think a sample text is necessary in this particular post, but if needed I can edit that in.

\usepackage{hyperref, xcolor, graphicx, textcomp}

\hypersetup{colorlinks=true, urlcolor=blue}


\title{Resequencing Analysis}



    $ mkdir ~/glob/gatk


I have now solved a part of the problem by using the environment


instead, but the tilde character still looks weird in the .pdf as it is raised up... If I use the $\sim$ it can't be copied into the terminal :/

  • 2
    A sample text is necessary. Look and copy&paste depends on the font and font encoding you are using. – Ulrike Fischer Jul 3 '14 at 8:34
  • Also it would show what packages you are using: where \texttildelow is defined for example – David Carlisle Jul 3 '14 at 8:37
  • I thought that the accsupp package, with something like \BeginAccSupp{ActualText={~}}\textasciitilde\EndAccSupp{} would work, but it does not: you can have two different symbols, one printed and one copy/pastable, but in that specific case it yield \protect\unhbox\voidb@x\penalty\@M\{}! – Clément Jul 3 '14 at 8:39
  • @UlrikeFischer Added the important parts from my text, as you can probably notice I am quite new to this. Any and all help is very much appreciated. – Rikardny Jul 3 '14 at 13:13
  • @DavidCarlisle So a more appropriate package can change the definition of '\texttildelow' to something that I would like? – Rikardny Jul 3 '14 at 13:14

You can use the accsupp package to set the text that is copied from the document separately from what the document displays.

For example, you could use \textasciitilde as your tilde in a command \actualtilde with



Here is my document text including a \actualtilde\ that copies correctly.

As for using this in a verbatim environment I am unsure, but if you put your code in a listings environment, this answer may be of assistance.

  • 1
    I like the idea of masking the text, that way the students can see the "right" tilde-sign, and also copy-paste it without getting some weird symbol in the terminal. Thanks, I'll look into it! – Rikardny Jul 3 '14 at 13:17

If you use \textasciitilde it will use a tilde character in ascii position if


is used. in the default OT1 encoding it uses a tilde accent over nothing as the fonts do not contain an ascii spacing tilde character (other than cmtt as used in verbatim)

The actual appearance depends on the font but in all cases it is a single character in position 126 so should cut and paste as such.

enter image description here

computer modern roman, computer modern tt and Times Roman




aaa\textasciitilde aaa

\texttt{aaa\textasciitilde aaa}


aaa\textasciitilde aaa

  • 3
    remembering the classic paper “goto considered harmful”, we could perhaps publish something like “ot1 considered harmful”. i would try to concoct something for the faq, if i was still working on it, but... – wasteofspace Jul 3 '14 at 9:12
  • So using \usepackage[T1]{fontenc} should put the tilde sign in the middle? I can't seem to get it to work, it just makes the pdf-text look weird. – Rikardny Jul 3 '14 at 13:25
  • @Rikardny see updated answer – David Carlisle Jul 3 '14 at 13:48

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.