1

Something is bothering me while I use LaTeX. If using, for example, Word, it will automatically capitalize the first letter of the beginning of each sentence and also suggesting to make some other punctuation etc.

At this point, is there any tool or package available for this matter for LaTeX?

yo'
  • 51,322
lonesome
  • 565
  • 11
    In my opinion, that's a bad habit; something as important and delicate as punctuation in a document shouldn't be delegated to a computer (at least not yet). – Gonzalo Medina Jan 18 '15 at 03:55
  • @GonzaloMedina but it can at least helps just like Word to at least remind if we forget and miss it. at least for me, as a non-native speaker, it will help a lot. punctuation in English kind of hard for me to follow in all cases. sometimes forget and sometimes doing it wrong. – lonesome Jan 18 '15 at 03:56
  • There is no package for this. In fact, it is is not the sort of thing (La)TeX should do for a variety of reasons. It is much better to ask a friend or colleague -- ideally one who is a native or fluent speaker -- to proofread it for you. – jon Jan 18 '15 at 04:34
  • 8
    I think this is more a question of editor choice instead of anything to do with LaTeX itself. Here's some examples of how to write LaTeX, though I'm not sure any of these provide capitalization/punctuation help... http://tex.stackexchange.com/questions/339/latex-editors-ides – Ryan Jan 18 '15 at 07:08
  • Since the question is about editor features, it is off-topic here and shoulb be migrated to one of our other sites. – Johannes_B Jan 18 '15 at 13:19
  • 4
    If you like Word's spelling correction you can use Word to type your latex files, you can use any editor to type latex, some have spelling correction some do not, but in any case it is nothing that latex itself is concerned with as it is a matter if fixing the input to latex. – David Carlisle Jan 18 '15 at 13:52
  • Are you aware that sometimes the first letter has to be left lowercase? [how-do-you-capitalize-a-proper-noun-such-as-iphone(http://english.stackexchange.com/questions/9063/how-do-you-capitalize-a-proper-noun-such-as-iphone). – g.kov Jan 18 '15 at 16:29
  • @g.kov such as? – lonesome Jan 19 '15 at 09:20
  • @user1064929: Such as for example, "iPhones are the best selling smartphones." from the link? – g.kov Jan 19 '15 at 10:47
  • @g.kov Oh I see. but it is just for Apple products. in fact, thought this is their slogan, but "I" is supposed to be capitalized in English when referring to oneself. so it is kind of their problem hehe, kidding. but except for Apple products, I guess for the rest it needs be capitalized. tell me if I am wrong. – lonesome Jan 19 '15 at 10:50
  • @user1064929: Ok, if you spend a minute to read the accepted answer and the relates questions at english.stackexchange.com, you can find out that "You should never change a brand name." Not only iPhones, e.g., iTeX, eBay, pH(from chemistry). They are never capitalized. Also, it could be, for example, a name of a variable in languages with strong typing, such as C:"ulAge contains the user's age in years." – g.kov Jan 19 '15 at 11:23
  • @g.kov sorry to make u angry, did not mean too. but as for brands name, i mean, it will just be like an exception, not very likely to happen often. but yea, that is a good one to point out – lonesome Jan 19 '15 at 12:54
  • If you start every sentence on a new line in your source code---a good practice in any case---then it is much easier to check on this, and it also will be easier to remember to do it to begin with, since before you type every sentence you'll type [end punctuation][return][Start new sentence]. – musarithmia Jan 20 '15 at 18:38

3 Answers3

7

This is a misunderstanding: LaTeX doesn't help you to write your text, which is the job of the editor. I'm quite confident that such a thing (capitalize each first letter after a dot) can be achieved with emacs or vim.

Word is all and everything in one: editor, typesetting machine, spreadsheet and so on and does nothing really well (OK, millions of people disagree).

As an alternative solution you could use Word as the editor:

Save your file as .txt and use latexmk to compile it in the background. Disclaimer: Did not try this myself; it is a really strange idea.

Ruben
  • 13,448
Keks Dose
  • 30,892
2

Not a solution, but a longer comment:

For some people, automatic capitalization of some word processors is a "bug", not a "feature". As pointed Gonzalo Medina. The reason is that in practice there are many exceptions, and supervise/correct every automatic decision is very distracting. In my case, overall I hate write correctly abbreviated name species (e.g., H. sapiens, etc.) and realize that the stupid computer wrote H. Sapiens (of course, only after print the "final" version in paper of high quality). This seem of little importance, but look like that the author unknown the basic rules of binomial nomenclature of the species. In high level scientific journals your article could be rejected only for this mistake.

On the other hand, as Ryan pointed, this a issue only related with the editor. Tex engines are WYWIWIP programs (What You Wrote Is What I Print) not WYMIWIR (What you Mean is What I Render). Then main purpose of a LaTeX compiler as pdflatex is not make source code, but read it in plain text (made with any other program). Thus, some source code (your preamble, or you custom class or package) must say what do do.

Think twice about left this job to LaTeX. In the editor side, the question is only if this justify a bloatware. With LaTeX, just think in the dot character. Make . an active character as & is not an option, since you have the same symbol for end of sentences (full stops), end of the paragraphs (not followed by spaces + some character), abbreviations within upper cases (J. Smith) or not (No. 3), decimals (3.14), ellipsis, ... Testing every case? Good luck with this adventure. Even is possible with LaTeX 3 or whatever, I only expect a massively overloaded, fragile and incompatible code.

Then, the natural LaTeX option, at least for a user without a deep understanding of the guts of TeX (i.e., me) would be replace the period at the end of the sentence by some odd macro like to act like a full stop that replace the next character after the space, whithout touching periods of abbreviations, end of paragraphs, etc. A simple approach:

\documentclass{minimal}
\def\¶{. \MakeUppercase}
\begin{document}
This is a test\¶ this is a test.
\end{document}

This MWE produce:

This is a test. This is a test.

Using newunicodechar package you can even convert in only or some other non ASCII character:

\documentclass{minimal}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}
\newunicodechar{¶}{. \MakeUppercase}
\begin{document}
This is a test¶ this is a test.
\end{document}

But is not so simple. Try simple constructions as ¶{\em this} or ¶\emph{this} in this MWE.

Anyway, the main drawback is no that, but the sacrifice of readability and easy writing because a little fix that is easily done by hand.

Fran
  • 80,769
1

Actually you can capitalize the beginning of a new sentence by making . active and redfine it to first test if a space is following the period and then executing \ucmacro (a macro version of the \uppercase primitive) when a space was found and to print whatever was found when it wasn't a space:

\documentclass{article}

\begin{document}
\let\period=.
\catcode`\.=13%\active
\catcode`\@=11%letter
\def.{\period\afterassignment\@period\let\next= }
\def\@period{%
  \if\noexpand\next\@sptoken
    \next\expandafter\ucmacro
  \else
    \expandafter\next
  \fi
}
\def\ucmacro#1{\uppercase{#1}}
\catcode`\@=12%other

zzzzzzzz. capitalize this.but not this.
\end{document}

With honorable mentions to @egreg's answer on \let\foo\bar vs \let\foo=\bar

output

Ruben
  • 13,448
  • There might be places where this fails, e.g. here. – Johannes_B Jan 18 '15 at 15:35
  • @Johannes_B, do you alredy have an idea where exactly? – Ruben Jan 18 '15 at 15:36
  • 1
    Will the h get capitalized? e.g. h from above. – Johannes_B Jan 18 '15 at 15:38
  • 4
    @Ruben Nice, but bound to break almost every usage of the period not as punctuation (in coordinates for a picture, for instance, or in \hspace{1.5em}). – egreg Jan 18 '15 at 16:04
  • @egreg, I feared that. Do you think it would make sense to define \def\makeperiodactive{\catcode`\.=13} and \def\makeperiodother{\catcode`\.=12} and switch by hand. In the manuscript itself it should not occur too often, I'd say. – Ruben Jan 18 '15 at 16:53
  • That would be a “solution”, but I'm not really sure it makes the document better. Automatic grammar control can fail in several cases, e.g. this one. (Same self-reference as used by @Johannes_B.) If the period is active, the t after e.g. would become uppercase. – egreg Jan 18 '15 at 17:10
  • @egreg and the S after ( would not. I wonder when people realize that automation like this is just completely unreliable hell on earth. Oh, I forgot that with the current state of education of the nations, such automated tool, no matter how bad, performs zillion times better than an average person. :( – yo' Jan 20 '15 at 13:24
  • ime, writing this sort of code is most useful as a distraction when you can't get the words to flow when you're composing your paper (or in my case, faq answer...) – wasteofspace Jan 20 '15 at 20:30