4

[Moved from StackOverflow.com]

How can I format certain characters without using macros? For example, if I want to make all instances of the character ‘f’ bold, how can I make TeX do it automatically?

I’m using XeLaTeX to process my document.

(Actually, the document is written in Simplified Chinese. The Asian full stop symbol (‘。’, U+3002) in my fonts, however, have their small circle placed at the center, which is inconsistent with the standard of the Chinese Mainland. Since full stops appear after every sentence, it would seem too cumbersome to use macros.)

Stefan Kottwitz
  • 231,401
ȷ̇c
  • 1,841

3 Answers3

4

One way is to make the char active and then define it. Here an example (its dangerous to do it for ascii chars I'm doing it only as example!)

\documentclass[a4paper,10pt]{article}

\begin{document}
\begingroup
\catcode`\y=\active
\defy{\textbf{\char121}}
abcyyabc
\endgroup
\end{document}

If you only want to use another glyph in your font you can also use a mapping, like the tex-text mapping which maps e.g. -- to \endash. You need teckit to generate such mappings.

http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=TECkit

Ulrike Fischer
  • 327,261
1

If you're talking about characters in text mode, I'm afraid there isn't a good way to do this automatically. However, Paul Isambert's xesearch package might be able to achieve the effects you're after.

0

You'd better use a Chinese font for Simplified Chinese, e.g. 'SimSun', 'Adobe Song Std' and free 'AR PLBaosong2GBK Light'. The full stop is at correct position for Chinese Mainland.

In XeTeX, these work can be done by using \XeTeXinterchartoks and \XeTeXcharclass, this is how xeCJK and ucharclass package works. See this question for detailed (but lowlevel) example: Font selection in XeTeX for specific characters

BTW, it seems you didn't know xeCJK package. It can deal with Simplified Chinese punctuations properly.

Leo Liu
  • 77,365
  • Thanks and yes I do know and use the xeCJK package which is almost mandatory for typesetting Chinese text (isn’t it?) and have quite a number of Chinese fonts (most are Big5-encoded). My current solution is based on Ulrike's answer. – ȷ̇c Feb 24 '11 at 06:06
  • Big5 fonts may be still inconsistent with the standard of the Chinese mainland, some glyphs are different. Strict publishers might refuse to use them. In addition, some OpenType fonts, like Adobe Song Std, support different punctuation positions. – Leo Liu Feb 24 '11 at 10:13