I already read Automatically convert "..." to "\ldots" but this question was asked/answered to help the asker save a lot of replace operations through several files.

In my case, I'm trying to \input several files of separate scenes (for a novel) that conform a whole story. I'm interested in keeping the separate files as plain as possible, which means I want to use the fewer TeX/LaTeX commands. Reason is I'll be sending the separate files for revision, and having a lot of \ldots in text makes for a harder reading/revising. However, I would like to use a font other than Linux Libertine or Junicode, so the referenced solution will not primarily work for my document.

I could, of course, wait until the end of the revision process and then batch-replace. However, I was hoping for a better -more programmatic way- of replacing "..." with an ellipsis, without actually modifying the source files to replace each with \ldots.

Example of main.tex:



Example of mynovel.sty:

% Most code here is to provide a lettrine automatically
\def\capitalize#1#2 {
    % some code here explicitly omitted

Example of stories/first_story.tex:

Había una vez un hombre. El hombre dijo:

---Buenos días... ¿me da una taza de café?
  • 1
    Have you considered writing in markdown and using pandoc to convert to LaTeX when needed?
    – Seamus
    Feb 18, 2016 at 14:55
  • @lorenzo-pena are you going to be using Linux Libertine or Junicode for your final output? If so I don't understand what your problem would be. Have you tried \input <file> in your master document and that did not convert the periods to ellipsis in the <file> portion of your final output?
    – A Feldman
    Feb 18, 2016 at 15:23
  • @Seamus, I wouldn't want to write in markdown. Feb 18, 2016 at 15:40
  • @lorenzo-peña what would you MWE look like?
    – A Feldman
    Feb 18, 2016 at 15:41
  • 1
    @lorenzo-peña do you mean "make ebgaramond" work for me like that?" If so I think there might very well be. Why don't you post a MWE both for your master file, and an example of your input file.
    – A Feldman
    Feb 18, 2016 at 15:52

3 Answers 3


If you can use LuaLaTeX, i.e., the LaTeX format with the LuaTeX engine (instead of the pdfTeX engine), it is straightforward to write a Lua function that replaces all instances of ... with \dots "on the fly", at a very early stage of the compilation process (before TeX starts its usual processing).

The following example sets up such a Lua function, named dots2ellipses, and provides two LaTeX macros, named \dotstoellipsisON and \dotstoellipsisOFF, which activate and deactivate the operation of the Lua function.

enter image description here

(The code uses "Arno Pro" rather than "EB Garamond" since the former generates a more easily visible difference of the appearance of "..." and "\dots".)

% !TEX TS-program = lualatex
\setmainfont{Arno Pro} % for a clear difference between "..." and "\dots"

%% Lua-side code
function dots2ellipses ( buff ) 
   return ( buff:gsub ( "%.%.%." , "\\dots{}" ) )

%% TeX-side code: macros to switch Lua function on/off
   "process_input_buffer", dots2ellipses, "dots2ellipses" )}}
   "process_input_buffer", "dots2ellipses" )}}

here ... there ... everywhere --- with ``\textbackslash dots''

here ... there ... everywhere --- without ``\textbackslash dots''

  • 1
    Thanks, the substitution scheme was also helpful in dealing with broken ---. and ---, across lines, I am now automatically enclosing them in \mbox{}. Feb 18, 2016 at 17:12
  • Does this method have any advantage over defining a feature (e.g., feature dlig {sub \period \period \period by \ellipsis;} dlig;)?
    – Thérèse
    Feb 18, 2016 at 19:14
  • @Thérèse - Not sure if it amounts to an "advantage", but the Lua function given in the answer does exactly one thing (and only one thing...). In contrast, depending on the font that's in use, turning on the dlig feature may activate other dlig-related activities -- in addition to the replacement of ... with \dots{} that would be specified in a feature file. Separately, the code given in the answer allows for easy activation and deactivation of the Lua function, without having to switch to a different font family (i.e., one for which the feature file isn't being loaded).
    – Mico
    Feb 18, 2016 at 19:24
  • with encTeX you spare a Lua function with an extended TeX primitive.
    – jarnosc
    Mar 3, 2016 at 19:30
  • @erreka - I'm afraid I'm utterly unfamiliar with encTeX. Would you mind explaining what it is and how your comment relates to the posting and/or my answer?
    – Mico
    Mar 3, 2016 at 23:44

If you use any format (Plain, LaTeX) with an active encTeX engine you can write something like this:

\mubytein=1 % make it 0 to turn off conversion

something ... or another

and you get the expected output. encTeX is available in 8bit TeX engines (Knuth, eTeX, pdfTeX).

  • @LorenzoPeña There exists a possibility to re-generate LaTeX format with encTeX activated. If you do this then you can use \mubyte in LaTeX too.
    – wipet
    Feb 18, 2016 at 15:42
  • only encTeX is needed; csplain is not required.
    – jarnosc
    Mar 3, 2016 at 19:18
  • 1
    @wipet Can this solution be used with XeLaTeX and LuaLaTeX?
    – A Feldman
    Mar 3, 2016 at 20:55
  • @AFeldman No, these engines have totally different input processor. They have other tools to control the behaviour at input processor level (lua scripts for example).
    – wipet
    Mar 3, 2016 at 21:08
  • @AFeldman you may request the inclusion of the encTeX primitives on those engines, of course...
    – jarnosc
    Mar 3, 2016 at 22:08

Try this, compiling with xelatex:



    Hello ... World

  • Any workaround to make it work with input files? It works when I type text directly into the main.tex file, but not when inputting content from other files. Feb 18, 2016 at 16:29
  • @LorenzoPeña not that I could find. Kudos to Mico for a fully working answer.
    – A Feldman
    Feb 18, 2016 at 17:02
  • 1
    @AFeldman ... if you happen to be using LuaLaTeX.
    – jarnosc
    Mar 3, 2016 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .