LaTeX forum ⇒ TeXworksmistakes on typing |

Information and discussion about TeXworks, an integrated LaTeX environment for several platforms
yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

mistakes on typing |

Postby yaozhao » Sun Oct 28, 2018 8:28 pm

The question is simple. I want to type |left|left|right|.

But the outcome after clicking on typesetting button is shown: —left— left —right

It's dash, rather than my desired |.

Many thanks in advance!

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
User avatar
Stefan Kottwitz
Site Admin
Posts: 9878
Joined: Mon Mar 10, 2008 9:44 pm

mistakes on typing |

Postby Stefan Kottwitz » Sun Oct 28, 2018 11:31 pm

The | is one of the special symbols that are not supported in the old default original font encoding of LaTeX. You can switch to a modern font encoding this way, then it works:

\usepackage[T1]{fontenc}

Stefan
LaTeX.org admin

yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

mistakes on typing |

Postby yaozhao » Mon Oct 29, 2018 2:49 am

Great, that works! Thank you so much!

Could you explain what's the distinguishable function of this package [T1]{fontenc}?

User avatar
Johannes_B
Site Moderator
Posts: 4183
Joined: Thu Nov 01, 2012 4:08 pm

mistakes on typing |

Postby Johannes_B » Mon Oct 29, 2018 3:59 am

By the way, i can recommend a great read: LaTeX for complete novices.
It is a free introduction written by Nicola Talbot that gets you familiar with all the basics you need.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9878
Joined: Mon Mar 10, 2008 9:44 pm

mistakes on typing |

Postby Stefan Kottwitz » Mon Oct 29, 2018 2:43 pm

The symbols in a font (glyphs) have to be used with an internal numbering. So we have tables with numbers for fonts. Assigning numbers to font elements is called encoding. It's similar to ASCII code but not just for standard characters but for font symbols, that can be thousands. The default encoding in LaTeX just supports fewer symbols, such as normal characters/letters. Letters with accents are then made as combination of latter and an accent symbol over it. Modern encoding, such as the so called T1 encoding, have big font tables with a lot of symbols including real accented letters and many more symbols. That's what this line above does, it activates that.

Using this, I also recommend to add

\usepackage{lmodern}

This changes the default font (Computer Modern) to Latin Modern that is very similar but with proper T1 encoding support. I would say it's better to use it.

Stefan
LaTeX.org admin


Return to “TeXworks”

Who is online

Users browsing this forum: No registered users and 1 guest