1

I created/copied this piece of latex preamble code:

\makeatletter
\def\@lesson{}
\def\@lessonabbr{}
\newcommand{\lesson}[4]{
    \ifthenelse{\isempty{#3}}{
    \def\@lessonabbr{Les #1}
        \def\@lesson{Lesson #1}
        \def\@fullLesson{\hfill \small{#2}\hr \@lesson \hfill \small{#4} \\}
        \subsection[\@lessonabbr]{\@fullLesson}
    \label{\@lesson}
    }{
    \def\@lessonabbr{Les #1: #3}
        \def\@lesson{Lesson #1: #3}
        \def\@fullLesson{\hfill \small{#2}\hr \@lesson \hfill \small{#4} \\}
        \subsection[\@lessonabbr]{\@fullLesson}
    \label{\@lesson}
    }
}
\makeatother

\lesson{1}{Mar 18 2022 Fri (16:40:24)}{Write an inequality from Graph}{Unit 2}

How would I make it automatically create a label for me by replacing the spaces with _ and making it all lowercased? I want to use the title of the lesson along with the lesson number. For this case, the label would look like this: les1:write_an_inequality_from_graph_unit_2

Any help will be greatly appreciated!

  • Maybe related: https://tex.stackexchange.com/questions/422181 and https://tex.stackexchange.com/questions/62217. – Dr. Manuel Kuehner Apr 02 '22 at 03:18
  • Also maybe related: https://tex.stackexchange.com/questions/631485 – Dr. Manuel Kuehner Apr 02 '22 at 03:19
  • generating a label, specially one that includes a generatd number negates most of the reason for having \label. The point of \label/\ref is that they use an internal idenifier so you can edit the document, re-order sections, change titles, ... but the \ref to the item still works. – David Carlisle Apr 02 '22 at 12:56
  • note \small does not take an argument so \small{#2} is the same as \small #2 and makes all the following text small, not just #2 – David Carlisle Apr 02 '22 at 12:57

0 Answers0