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.

Is there a way to automatically convert a basic string into a command, for example converting instances of ... to \ldots? I have to work with a large number of plaintext files, and doing a dozen find/replace operations for each file is rather inconvenient.

share|improve this question
4  
Welcome to TeX.SE. Seems like a job that could easily be done outside of TeX with a simple sed script. But how would you want to handle the case where these should instead be \cdots? –  Peter Grill Oct 22 '12 at 1:16
2  
@PeterGrill something like find -name '*.tex' -print0| xargs -0 sed -i 's/\.\.\./\\ldots/' :) –  cmhughes Oct 22 '12 at 1:37
    
@PeterGrill In text, ... should always be \ldots{}, so the case of \cdots{} might not apply to the OP. –  Bruno Le Floch Oct 22 '12 at 4:05
1  
With for example Notepad++ you can do one find/replace operation simultaneously on as many files as your memory allows to open. –  Qrrbrbirlbel Oct 22 '12 at 10:45
add comment

1 Answer

up vote 11 down vote accepted

There are some fonts that turn ... into Unicode Character 02026 "Horizontal Ellipsis" , e.g. Linux Libertine and Junicode, which have this transformation as part of the "Common" Ligature set (OpenType feature liga). Since both fonts activate the "Common" ligatures by default, you don't need to do anything but use the respective font. Here's an example of liga on and off, with the output, and the OCR Layer of the PDF, i.e. what's copy-pastable and findable with the search function:

% compile with XeLaTeX or LuaLaTeX
\documentclass{article}

\usepackage{fontspec}

\usepackage{libertineotf}

\begin{document}

\libertine Linux Libertine:

{\addfontfeatures{RawFeature=-liga} Hey ... what’s up?}

{\addfontfeatures{RawFeature=+liga} Hey ... what’s up?}

\fontspec{Junicode} Junicode: % you need to have the font installed

{\addfontfeatures{RawFeature=-liga} Hey ... what’s up?}

{\addfontfeatures{RawFeature=+liga} Hey ... what’s up?}

\end{document}

output

Linux Libertine:
Hey ... what’s up?
Hey … what’s up?
Junicode:
Hey ... what’s up?
Hey … what’s up?

(Adobe Reader 10.1.4 on Win7 is actually able to find all four three-dot combinations if you search for either ... or . Sumatra PDF 2.1.1 only finds the two specific ones for each.)

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.