I'm writing a report together with another person, and he often neglects to use a capital letter at the start of each sentence. Is it possible to get LaTeX to correct this automatically instead of doing so by hand?
[Tex/LaTex] Automatically capitalise the first word in each sentence
capitalizationpdftex
Related Solutions
\documentclass{article}
\usepackage{makeidx}\makeindex
\newcommand*{\formatfirst}[1]{\MakeUppercase{#1}}
\makeatletter
\newcommand*{\mymacro}[1]{%
\expandafter\formatfirst\expandafter{\@car #1\@empty\@nil}%
\@cdr #1\@empty\@nil}
\newcommand*\myMakeUpperCase[1]{%
\def\@myuppercasewords{\myuppercase@i#1 \@nil}%
{\itshape\@myuppercasewords}\index{#1@\@myuppercasewords}}
\def\myuppercase@i#1 #2\@nil{%
\mymacro{#1}%
\ifx\\#2\\%
\else
\@ReturnAfterFi{%
\space
\myuppercase@i#2\@nil
}%
\fi}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
\makeatother
\begin{document}
foo
\myMakeUpperCase{capital letter} bar
\myMakeUpperCase{Next one} baz
\myMakeUpperCase{two words}
\printindex
\end{document}
(Edited after I learned from the OP that the command is used in lyx.)
The simplest solution may be to define a new command, \Secref
, that starts with an uppercase letter S, as in
\newcommand{\Secref}[1]{Section~\ref{#1}}
That way, if you need the capitalized form of the noun, you can switch from \secref
to \Secref
.
If you're willing to use the cleveref
package, you could use the command \cref{2}
to generate Section 2
, and by typing \cref{2,3}
you'd generate Sections 2 and 3
; note the automatic use of the plural form of the noun in the second example. Cleveref's commands are "clever" enough (pun intended) to determine the type of the entity being cross-referenced, and the commands then select the noun that goes with it. The forms of the nouns (e.g., uppercase, lowercase) that get prefixed to the referenced entity are fully customizable. And, if you use babel
, the nouns will be set to any one of (currently) six or seven languages, i.e., you're not "stuck" with just the English language nouns. Finally, if you're so inclined, you can set up the package so that \cref
will use a lowercase starting letter while \Cref
will use an uppercase starting letter (useful when starting off a sentence with a cross-reference).
These examples assume that you've given the labels 2
and 3
to sections 2 and 3 of your paper. As a general comment, you may want to make a habit of using slightly longer label strings. One common technique is to start all equation labels with eq:
, all (sub,subsub)section labels with sec:
, all figure labels with fig:
, etc. If nothing else, using labels in this manner will save you a lot of time down the line when the need to debug some of the cross-references arises.
Best Answer
LaTeX is a set of macros for markup language TeX so definitely can't do anything. TeX maybe but sed (AWK, TCL, Perl, Python, Ruby) is the right tool for the job.