LaTeX users online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 2 guests

Underscore (_) symbol as "space" in the generated PDF

LaTeX Forum: Fonts & Character Sets

Add tags Information and discussion about fonts and character sets (e.g. how to use language specific characters)

Postby kulakov on Sat May 22nd, 2010

Hello LaTex experts,

I am new at LaTeX community and at LaTeX in general too, so please do not be hard when judging my post. I hope, the part of the forum I am pasting this question to is proper.

I am currently struggling with underscores in my generated pdf file. I have a lot of underscores in my text and I use the backslash "\" to avoid errors, which is the genral recomendation in all tutorial on how to work with underscores and other special characters. The underscores appear correctly in the generated PDF, however, the problem is that when I want to copy/paste the text with the underscores, I get spaces instead of underscores. For example, if I have the following text:
it appears OK in the PDF, but when I copy and paste it to a different file, I get the text as "This is a text with underscores", but not as "This_is_a_text_with_underscores" which is what I need.

I also noticed that if I search the PDF for the text "This_is_", I find no results, however if I search for "This is ", I find my text with underscores. It seems to me that the PDF file that is generated just displays the underscores, however, has spaces in the core of the document.

Can someone please tell me if this behaviour is expected? Or is this specific to the PDF generator? I am using TeXnicCenter tool.

I tried to use \textunderscore instead of \_ or even tried the behaviour when using package "underscore.sty", but I still have the same problem! Does anyone have an idea? I've already search the whole internet and the LaTeX community, but did not find anything with this problem.

Any help will be highly appreciated!

Thank you in advance.
Last edited by kulakov on Sat May 22nd, 2010, edited 1 time in total.
Posts: 2
Joined: Sat May 22nd, 2010

Postby localghost on Sat May 22nd, 2010

The code below works for me as expected. Copying and pasting parts of text yields the desired result as well as searching the PDF file. Perhaps a matter of the viewer.
Code: Select all  •  Open in online LaTeX editor


Best regards and welcome to the board
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes

¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses
User avatar
Site Moderator
Posts: 9218
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Postby kulakov on Sat May 22nd, 2010

Thorsten! You are the man! Thanks for your quick help! :)

This line made a difference:

If I change T1 to OT1 the old problem occurs, even with your simple example. I guess there is something wrong with the encoding OT1.

After I entered this line in my document it now works as expected! I got some issue with the text getting thinner and duller, but I was able to quickly solve it with the package "lmodern" as suggested in this post:

Danke viel Mals!
Schöne Grüße aus Wien!
Posts: 2
Joined: Sat May 22nd, 2010

Return to Fonts & Character Sets

LaTeX users online

Users browsing this forum: No registered users and 2 guests