0

MWE:

\documentclass[12pt]{article}

\usepackage{algpseudocode}
\usepackage[capitalize]{cleveref}


\begin{document}

\begin{algorithmic}[1]
\State\label{line} Hello World
\end{algorithmic}

This is a reference to \cref{line}.

\end{document}

The last line then reads: This is a reference to Line 1, but I would like it to be This is a reference to line 1. Of course, I could achieve this by removing the capitalize option, but I would like to keep things like theorems and algorithms capitalised.

1

Tell cleveref that “line” should be lowercase.

\documentclass[12pt]{article}

\usepackage{algpseudocode}
\usepackage[capitalize]{cleveref}

\crefname{line}{line}{lines}

\begin{document}

\section{Title}\label{sec}

\begin{algorithmic}[1]
\State\label{line} Hello World
\end{algorithmic}

This is a reference to \cref{line}.

We're in~\cref{sec}.

\Cref{line}

\end{document}

enter image description here

  • That kind of works, but runs into trouble if you do want an uppercase "Line", e.g. at the beginning of a sentence. – gTcV Apr 12 at 1:08
  • @gTcV Updated... – egreg Apr 12 at 6:16
0

Either don't use the capitalize option or workaround:

\documentclass[12pt]{article}

\usepackage{algpseudocode}
\usepackage[capitalize]{cleveref}


\begin{document}

\begin{algorithmic}[1]
\State\label{line} Hello World
\end{algorithmic}

This is a reference to \lcnamecref{line}~\ref{line}.

\end{document}
  • Sorry, I should have made clear that I want to keep the capitalize option for all other references. And the workaround is a bit cumbersome... – gTcV Apr 11 at 14:29
  • @gTcV If you want capitalization for all other references, why not for the line? Making it lowercase seems very inconsistent then – user185511 Apr 11 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.