Text FormattingIgnored hyphens between random words and numbers

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
FinTex
Posts: 3
Joined: Tue Nov 16, 2010 1:50 pm

Ignored hyphens between random words and numbers

Post by FinTex »

Hi, I am currently writing my thesis and encountered a problem with one of the references to an academic paper. Specifically, one hyphen was deleted from wherever one was placed in the source (e.g. cat-dog produced catdog, 350–-354 produced 350–354 (short hyphen). I initially thought this could be a problem with the link between jabref, bibtex and latex but when I copied the offending reference from the bbl file and into a separate .tex file it produced the same error. Here is the trimmed source:
%-----------------------------------------
\documentclass[12pt,a4paper]{report}
\begin{document}
Elastic–plastic, stress-strain, model-independent, , high-resolution\\
350–-354, 130--136
\end{document}
%-----------------------------------------
On my installation this produces hyphens between "Stress-strain", "model-independent" and "high-resolution" but doesn't for "elastic–plastic". It also produces a long dash for "130--136" but only a normal hyphen for "350--354".

I am at a loss to explain this, particularly since it only arises for a single reference and hundreds of others work fine - can anyone help?
Last edited by FinTex on Wed Nov 17, 2010 7:28 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Ignored hyphens between random words and numbers

Post by meho_r »

Try this:

Code: Select all

\documentclass[12pt,a4paper]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document} 
Elastic–plastic, stress-strain, model-independent, , high-resolution\\
350–-354, 130--136
\end{document}
FinTex
Posts: 3
Joined: Tue Nov 16, 2010 1:50 pm

Re: Ignored hyphens between random words and numbers

Post by FinTex »

Thanks for the suggestion meho_r,
When I include either of these options the missing hyphens appear as if a \H{U} command was entered.
Any idea what this means?
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Ignored hyphens between random words and numbers

Post by meho_r »

Let me guess, you're using TXC, right? The problem is that you're using en-dash by entering it as a single character, and that requires UTF-8 input encoding (which TXC, if you're using it, doesn't support yet). So, you should either:
  • 1. use UTF-8 input encoding with an editor which actually does support it, or
    2. use dashes "TeX-way", i.e.: one dash for "short" dash, two dashes for an en-dash and three dashes for an em-dash. Here's how your example should look in this case:

Code: Select all

\documentclass[12pt,a4paper]{report}

\usepackage[T1]{fontenc}% it is a good idea to have this in any case, utf-8 or not

\begin{document} 
Elastic--plastic, stress-strain, model-independent, ---, high-resolution\\
350--354, 130--136
\end{document}
FinTex
Posts: 3
Joined: Tue Nov 16, 2010 1:50 pm

Re: Ignored hyphens between random words and numbers

Post by FinTex »

I use both TexMaker and TeXnicCenter. I have managed to set TexMaker to run in utf-8 and compile with XeTeX. Now I think I see the problem... The source now puts a square character where the problem hyphens used to appear. I suspect that this reference was copied and pasted into JabRef from a pdf file which can screw up the characters. While they appeared as hyphens in the source, they were being interpreted as unknown characters and ignored.
The obvious solution is just to delete the hyphens which don't appear and re-type them - it will look the same but be interpreted very differently. Seems stupidly simple now - thanks for your help meho_r!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Ignored hyphens between random words and numbers

Post by localghost »

Now that the problem seems to besolved, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Otherwise please tell us what is missing. Please keep that in mind for the future so that further reminders will not be necessary.


Best regards and welcome to the board
Thorsten
Post Reply