Fonts & Character SetsLigatures

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
tdc
Posts: 34
Joined: Fri Sep 12, 2008 1:52 am

Ligatures

Post by tdc »

Hi there, i was wondering if there is an alternate way to code ligatures...

Specifically, rather than using \u{a} to get a breve above an a, is there another way to do this.

(I already defined \u as something, and then discoved on reading through a draft chapter that teh breves had been replaced by something entirely different! .. and there's a lot less uses of a breve in my document so it'd be easier redefining that :D)

Thanks for any help,

Tim

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Ligatures

Post by localghost »

What you call a ligature is usually known as accent. Moreover you should never define a command with only one character in its name. As you now have experienced, this can cause problems.

I guess your main problem is that you want to type special language characters (like "ä", "ö", "ü" and "ß" for me in German) directly in your source. If so, use the inputenc package along with the fontenc package.

Code: Select all

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
An alternative to inputenc is the selinput package from the oberdiek bundle. It chooses input encoding automatically by a list of given glyphs which are to be chosen from a glyph list. This is the way I set input encoding in my documents.

The fontenc package ensures correct hyphenation in your language, which you can set with the babel package.


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Ligatures

Post by phi »

LaTeX always converts characters to their internal representation first, which is "\u a" for ă. To change this, you have to redeclare the \u accent. How to do this depends on the chosen font selection, and it's generally not advisable to change such low-level commands. If you really need to redefine \u, then copy the original definition into a different macro:

Code: Select all

\newcommand*{\origu}{}
\let\origu\u
\renewcommand*{\u}{X}
...
\u a \par \origu a
It would be better, though, not to redefine \u in the first place.

PS: ˘ is a diacritical mark, not a ligature.
tdc
Posts: 34
Joined: Fri Sep 12, 2008 1:52 am

Re: Ligatures

Post by tdc »

Thankyou very much :)

Phi's solution worked a treat, the reason for using \u (and many other single letter commands, is i'm using many many vectors. However i now realise how careful i need to be about reassigning commands :D

Thanks again :D

Tim
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Ligatures

Post by phi »

If the command has to be valid in math mode only, you can redefine it to have different meanings in math and in text mode:

Code: Select all

\usepackage{fixltx2e}
\newcommand*{\origu}{}
\let\origu\u
\renewcommand*{\u}{\TextOrMath{\origu}{\vec u}}
I think this is OK because the two definitions never interfere: In text mode, the original command is still used; in math mode, your definition is used. This shouldn't cause problems because \u had been illegal in math mode before.
Post Reply