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
1  
Why do you want to do this? Maybe there is an easier way? –  Seamus Jan 12 '12 at 12:14
2  
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
4  
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
show 2 more comments

2 Answers

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

\catcode`\.=13 % make "." active
\def.{Lalala}

(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.

\documentclass{article}

\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
\def.{\period}

\renewcommand{\thesubsection}{\thesection\period\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection\period\arabic{subsubsection}}

\usepackage{enumitem}

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

\begin{document}
\tableofcontents
\section{section}
\subsection{subsection}
\subsubsection{subsubsection}

\begin{enumerate}[label=\arabic*\period]
    \item numbered list
    \item \texttt{\textbackslash ldots}: \ldots
\end{enumerate}

\lipsum[1]
\end{document}

share|improve this answer
3  
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
4  
+1 for a neat solution -- "smells like trouble" is worth an upvote all on its own. –  Brent.Longborough Jan 12 '12 at 10:10
1  
@PeterGrill: fixed for subsections and subsubsections (and numbered lists). –  doncherry Jan 13 '12 at 18:08
add comment

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
add comment

Your Answer

 
discard

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.