3

I have a section like this in my document.

\section{\textit{Use case} 5: Restore backup}
\label{sec:UC5}

I am using the hyperref package to make references that includes the content of the section in stead of the section number. This is all fine.

My problem is when I have a section like this: Use case 5: Restore backup, and referring to it it will look like this inside of my text:

some text... Use case 5: Restore backup ... some text.

But I would like it to be like this:

some text... use case 5: Restore backup ... some text.

note the lower case of the first word in the reference. How can I achieve this?

My document:

\section{\textit{Use case} 4: Save backup}
\label{sec:UC4}
\subsection*{Normalforløb}
Some text. Some text. Some text. Some text. Some text. Some text. Some text. \textit{\nameref{sec:UC5}}.

\subsection*{Undtagelser}
TBD

\section{\textit{Use case} 5: Restore backup}
\label{sec:UC5}
\subsection*{Normalforløb}
Den nye opdatering bliver slettet og backuppen geninstalleres. Backuppen skal verificeres efter installering.

I am adding the hyperref package like this:

\usepackage[plainpages=false,pdfpagelabels,pageanchor=true]{hyperref}

Here is a working sample: https://www.sharelatex.com/project/5409b0ac60203fdd22253e39

6
  • 1
    Please provide an MWE which makes it easier for us to help you. Thanks. Maybe the easiest would be to write \hyperref[sec:UC5]{use case 5: Restore backup}
    – LaRiFaRi
    Sep 5, 2014 at 9:14
  • I am not shure what it is you would like me to add or what you are suggesting. I will add a working example i 2 sec.
    – 7heViking
    Sep 5, 2014 at 10:19
  • 2
    hard to say without more context but almost certainly the markup should be \section{Restore backup} not \section{\textit{Use case} 5: Restore backup} font commands and explicit numbers are normally to be avoided in headings (well everywhere, but especially headings) then you can arrange that the heading and cross reference macros add use case or Use case as required. Sep 5, 2014 at 10:23
  • You are right about the numbering. But this case is a little odd because the numbers has to be static no matter which changes are made later on. I have just added a Little bit of code.
    – 7heViking
    Sep 5, 2014 at 10:26
  • @DavidCarlisle I often has such headings, for example if I write a memo commenting on an agreement: 1. Section 4.2: Unreasonable restriction (body text) 2. Subsection 5.1.2: Not relevant ( more body text). The section etc refer to the sections in the agreement I am commenting.
    – Sveinung
    Sep 5, 2014 at 11:33

1 Answer 1

4

This uses the \firstToLow command from this related answer:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[plainpages=false,pdfpagelabels,pageanchor=true]{hyperref}

\usepackage{mfirstuc}

\newcommand\firstToLow[1]{%
 {%
   \renewcommand{\mfirstucMakeUppercase}{\MakeLowercase}%
   \makefirstuc{#1}%
 }%
}

\makeatletter
\newcommand*{\lcnameref}[1]{%
 \begingroup 
   \let\label\@gobble
   \NR@setref{#1}\lc@thirdoffive{#1}%
  \endgroup
}
\newcommand{\lc@thirdoffive}[5]{\firstToLow{#3}}
\makeatother

\begin{document}

\section{\textit{Use case} 4: Save backup}
\label{sec:UC4}
\subsection*{Normalforløb}
Some text. Some text. Some text. Some text. Some text. Some text.
Some text. \textit{\lcnameref{sec:UC5}}.

\subsection*{Undtagelser}
TBD

\section{\textit{Use case} 5: Restore backup}
\label{sec:UC5}
\subsection*{Normalforløb}
Den nye opdatering bliver slettet og backuppen geninstalleres.
Backuppen skal verificeres efter installering.

\end{document}

This produces:

Image of result

3
  • I now realize that it produces some other troubles for me when using the @ sign in commands like \@title or \f@size. Do you know why this is problematic? I can upload the code if you would like it.
    – 7heViking
    Sep 5, 2014 at 12:45
  • Here is a working sample: sharelatex.com/project/5409b0ac60203fdd22253e39
    – 7heViking
    Sep 5, 2014 at 12:52
  • 1
    @FireFly3000 Internal commands (those containing @ signs in their name) don't work in ordinary use. See the TeX FAQ for further details. If the FAQ answer doesn't help, either open a new question as a follow-up (linked back to this one) including a minimal working example (MWE) or add a MWE to this question. Sep 5, 2014 at 14:50

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.