Text FormattingExtended ASCII Characters in the Source Code

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Gottfried
Posts: 5
Joined: Mon Aug 05, 2013 3:56 pm

Extended ASCII Characters in the Source Code

Post by Gottfried »

How do I type extended ASCII characters into LaTeX documents?

I think I add \usepackage[utf8]{inputenc} to the preamble. But how do I define the character. Lets say I only know the number of the character I need to add in the extended ASCII set?
Last edited by cgnieder on Wed Aug 07, 2013 9:33 am, 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.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Extended ASCII Characters in the Source Code

Post by localghost »

What are extended ASCII characters in your understanding? And what do you mean with "define a character"? Which characters exactly do you want to type.


Thorsten
Gottfried
Posts: 5
Joined: Mon Aug 05, 2013 3:56 pm

Extended ASCII Characters in the Source Code

Post by Gottfried »

http://ascii-code.com/

Micro sign (181), trade mark sign (153), left double angle quotes (171) and right double angle quotes (187), the section symbol (167), and single left and right angle quotes (139), (155), trade mark sign (153).

I insert them as symbols usually in a word processor and copy and past them but I need to convert many documents to latex which contain these symbols. The first four occur frequently.

Is it possible to get the section sign in front of the number in the article class for section headings, too?

I am using Gummi on Linux to edit.

Thank you in advance for all advice.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Extended ASCII Characters in the Source Code

Post by Johannes_B »

There are different ways to inpt those charakters. If your file is ASCII-encoded, you to tell LaTeX with commands/macros what to do/typeset. If your file is encoded in unicode, you can enter most of those signs directly.
You can click on Open in writelatex and check it out.

Code: Select all

\documentclass[a4paper]{article}

\usepackage[french,ngerman,english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[autostyle=true]{csquotes}
\usepackage{upgreek}
\usepackage{textcomp}

\begin{document}
normal $\mu$ and $\upmu$ using package upgreek

µ input via unicode

\S{} and §

``text in `quotes'"

Smart quotes using package enquote
\enquote{text in \enquote{quotes}}

\glqq enquotet text\grqq

\flqq enquotet text\frqq



\selectlanguage{french}
\enquote{text in \enquote{quotes}}

\selectlanguage{ngerman}
\enquote{text in \enquote{quotes}}

\texttrademark

\"a or just ä

\end{document}
Last edited by Johannes_B on Fri Aug 09, 2013 2:02 pm, edited 1 time in total.
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
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Extended ASCII Characters in the Source Code

Post by localghost »

Gottfried wrote:[…] Micro sign (181), trade mark sign (153), left double angle quotes (171) and right double angle quotes (187), the section symbol (167), and single left and right angle quotes (139), (155), trade mark sign (153). […]
On Linux I have no problem to produce these characters (on my German keyboard).
  • µ: "Alt Gr"+"M" or \textmu from textcomp
  • ™: "Shift"+"Alt Gr"+"8" or \texttrademark
  • «: "Alt Gr"+"X"
  • »: "Alt Gr"+"Y"
  • §: "Shift"+"3" or \S
  • ‹: "Shift"+"Alt Gr"+"X"
  • ›: "Alt Gr"+"Y"
If you have another keyboard layout, you may need to search the internet on how to produce the characters. At least for the first two symbols you can take a look at »The Comprehensive LaTeX Symbol List«. Note that you need the correct input encoding if you want to produce the characters directly.
Gottfried
Posts: 5
Joined: Mon Aug 05, 2013 3:56 pm

Extended ASCII Characters in the Source Code

Post by Gottfried »

I have a standard wireless US keyboard everywhere. No AltGr key. Also it is not present on my laptops. Ctrl + Alt as subsitute does not work. I have to directly code it in I think or get the program to do so. I can copy and paste the symbols from documents or internet but they don't display.

Copy and pasting

Code: Select all

«text» § µ ™
displays

Code: Select all

text
.

I am using these packages as standard:

Code: Select all

\documentclass[12pt]{article}
\usepackage[usenames]{color}
\usepackage{booktabs, graphicx}
\usepackage[top = 1in, bottom = 1in, left = 1in, right = 1in]{geometry}
I need perhaps another package loaded?

Do I understand correctly that merely typing the character in produced the displayed character in pdflatex output?

Adding in

Code: Select all

\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{upgreek}
\usepackage{textcomp}
does not get the symbols to display.

Adding in

Code: Select all

\usepackage[utf8]
or

Code: Select all

\usepackage[utf8]{inputenc}
results in error.

Code: Select all

\texttrademark

\S{}

$\mu$
Works as macros for ™ § µ. But I cannot get the various quotes working. I can get English standard single or double quotes in many ways, but not the angle quotes without enabling and typing in another language
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Extended ASCII Characters in the Source Code

Post by Johannes_B »

Your files have to be utf8-encoded, your editor can do so. If not, get another. Which one do you use? Please click on open in writelatex in my previous post to see the output.

Read the csquotes-documentation to learn, how to change the output to guillemets. I also changed my previous post, have a look.

Please prepare a minimal working example for follow up questions, code snippets are hard to deal with.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Gottfried
Posts: 5
Joined: Mon Aug 05, 2013 3:56 pm

Extended ASCII Characters in the Source Code

Post by Gottfried »

Johannes_B wrote:Your files have to be utf8-encoded, your editor can do so. If not, get another. Which one do you use? Please click on open in writelatex in my previous post to see the output.

Read the csquotes-documentation to learn, how to change the output to guillemets. I also changed my previous post, have a look.
Thank you! That example worked. I will now use babel + csquotes for all quotation related things from now on. It saves much time, I can already see. :D

As for utf8-encoded, I don't know how to do that. Trying to load the the package utf8 crashed it. I started with the default .tex file loading in Gummi.

Gummi is my text editor in Linux. http://dev.midnightcoding.org/projects/gummi
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Extended ASCII Characters in the Source Code

Post by Johannes_B »

I never used gummi, have a look in the preferences or the "save as"-dialog. Maybe the encoding is changeable there. An up-to-date editor should support unicode. If you are open-minded you could try another editor. Texstudio, texmaker and texworks all support unicode and run on Wind0ws and *nixes.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply