Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to replace all dots in a LaTeX document with a call to a macro. Just doing a search and replace on '.' won't help as this will not replace the dots generated by LaTeX, e.g. in section numbers, enumerates, ...

share|improve this question
And by dots here you include (say) end-of-sentence periods and abbreviations? –  Werner Jan 11 '12 at 23:54
Yes. Each and every occurence of the '.' character that can be seen in the output. –  Fabian Jan 11 '12 at 23:55
Why do you want to do this? Maybe there is an easier way? –  Seamus Jan 12 '12 at 12:14
It's for a steganography challenge, I plan on using slightly different dots to encode a message in a longer document. –  Fabian Jan 12 '12 at 12:47
Your best bet is probably to use LuaTeX, catching dots as they are typeset. I wouldn't mess up with the fonts. –  Bruno Le Floch Jan 12 '12 at 13:36

2 Answers 2

You can assign . a different catcode, thus make it active and then define a macro . like this:

\catcode`\.=13 % make "." active

(adapted from http://tex.stackexchange.com/a/40515/4012)

Note that this might get you into trouble. I don't know much about catcodes and active characters and the like, but redefining . smells like trouble.

This doesn't work for all periods in your text, though. I fixed the subsections and subsubsections and the numbered list. If you need another specific period to be replaced, let me know, I'll see what I can do.


\usepackage{adforn}% just for the flower symbol, not necessary for the replacement of "."

\newcommand*{\period}{\adforn{60}} % replace \adforn{60} with whatever
                                   % you want to have instead of "."

\catcode`\.=13 % make "." active



\usepackage{lipsum}% just for the Lorem ipsum text


    \item numbered list
    \item \texttt{\textbackslash ldots}: \ldots


share|improve this answer
Seems to work for most cases, but not when the . is auto generated such as in \subsection{First Subsection}. –  Peter Grill Jan 12 '12 at 3:04
+1 for a neat solution -- "smells like trouble" is worth an upvote all on its own. –  Brent.Longborough Jan 12 '12 at 10:10
@PeterGrill: fixed for subsections and subsubsections (and numbered lists). –  doncherry Jan 13 '12 at 18:08

That's not possible in a simple way. Making the dot active will not affect dots stored in macros before the catcode change. It works with \lipsum in the example of doncherry only because the package is loaded after the \catcode command – and doncherry has a lot chance that the dot is not used in lipsum in places (e.g. in a number) where the active dot would explode.

You should change the catcode of the dot only after \begin{document} and reset it at every place where the dot is used e.g. in a number.

To change the other dots you will have to carefully track down all commands that issues dots and redefine them.

Another way to replace every dot is to manipulate the fonts, but this isn't simple either as quite a lot fonts can be involved.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.