Featured Book

LaTeX Beginners Guide

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (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 1 guest

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

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

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

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

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:
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 22nd, 2010, edited 1 time in total.
kulakov
 
Posts: 2
Joined: Sat May 22nd, 2010

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

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 writeLaTeX
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}

\begin{document}
  This\_is\_text\_with\_underscores.
\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
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

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

Postby kulakov on Sat May 22nd, 2010

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
kulakov
 
Posts: 2
Joined: Sat May 22nd, 2010


Return to Fonts & Character Sets

Who is online

Users browsing this forum: No registered users and 1 guest

cron