TeXworksmistakes on typing |

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

mistakes on typing |

Post by yaozhao »

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 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

mistakes on typing |

Post by Stefan Kottwitz »

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 |

Post by yaozhao »

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: 4182
Joined: Thu Nov 01, 2012 4:08 pm

mistakes on typing |

Post by Johannes_B »

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: 10308
Joined: Mon Mar 10, 2008 9:44 pm

mistakes on typing |

Post by Stefan Kottwitz »

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
Post Reply