LaTeX forum ⇒ Fonts & Character SetsUnderscore (_) symbol as "space" in the generated PDF

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
kulakov
Posts: 2
Joined: Sat May 22, 2010 6:49 pm

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

Postby kulakov » Sat May 22, 2010 7:15 pm

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:
This_is_a_text_with_underscores
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.
Regards,
Maxim
Last edited by kulakov on Sat May 22, 2010 8:40 pm, edited 1 time in total.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Sat May 22, 2010 7:29 pm

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.
  1. \documentclass[11pt,a4paper,english]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage{babel}
  5.  
  6. \begin{document}
  7. This\_is\_text\_with\_underscores.
  8. \end{document}



Best regards and welcome to the board
Thorsten
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

Link:
BBcode:
HTML:
Hide post links
Show post links

kulakov
Posts: 2
Joined: Sat May 22, 2010 6:49 pm

Postby kulakov » Sat May 22, 2010 8:39 pm

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

This line made a difference:
\usepackage[T1]{fontenc}

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: http://mrunix.de/forums/showthread.php?t=57130.

Danke viel Mals!
Schöne Grüße aus Wien!
Maxim

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Fonts & Character Sets”

Who is online

Users browsing this forum: No registered users and 1 guest