# How to make the reference label start with a capital letter?

I have the following lines in my document:

In \secref{2}, a very basic review is presented. \secref{3} compares different structures.


\secref{3} must start with a capital letter. However, LaTeX makes it start with its ordinary label "section" (with a small "s").

How can I correct this?

PS: It does not need to be automatic. Any particular (manual) solution is fine for me.

-
Which LaTeX package provides the command \secref? –  Mico Sep 14 '11 at 18:21
It is a lyx generated command: \secref[1]{\ref{sec:#1} –  user460153 Sep 14 '11 at 18:25
Thanks. I've adjusted the first paragraph of my answer below now that I know it's a lyx command. –  Mico Sep 14 '11 at 18:51

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

-
Good comment with respect to label strings. –  lockstep Sep 14 '11 at 18:52

LyX uses the refstyle package to format cross-references. refstyle supports capitalized macro versions like \Secref for use at the start of sentences. I don't know if LyX features an interface for \Secref & friends -- if not, insert the command as "evil red text" (LaTeX code).

For users that don't depend on LyX: The cleveref package also features capitalized macro versions, and its \cref/\Cref macro is able to automatically detect label types and to format cross-references accordingly.

\documentclass{article}

\usepackage{cleveref}

\begin{document}

\section{bla}\label{1}

In \cref{2}, a very basic review is presented. \Cref{3} compares different structures.

\section{blubb}\label{2}

\section{foo}\label{3}

\end{document}

-
+1 for cleveref. I'd add that you can customize \cref for all of the objects that it references. In the case of sections, you can use something like \crefname{section}{Section}{Sections} for \cref, and \Crefname{section}{Section}{Sections} for \Cref –  cmhughes Sep 14 '11 at 18:54