diff --git a/CHANGELOG.md b/CHANGELOG.md index a2b909e4739d11c09a8041af5c5b86c591a1e72f..0edcb9e9f69aa55eed95b395b818bb8d2c5bd201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. ## [Current] +### Changed + +- `\title` now accepts an optional argument. It will be used as a short version of the title and will be put into the header. + ### Fixed - `\ihead` and `\ohead` now have a max width and will break into multiple lines (#7) diff --git a/HsH-classes.dtx b/HsH-classes.dtx index d9db6f9bc11be6d22ae4c191d61abd815314ac50..1c3869ee4adcca04099865904e1b0bfab1f89af6 100644 --- a/HsH-classes.dtx +++ b/HsH-classes.dtx @@ -143,6 +143,12 @@ %<*article|report> %% title matters ---------------------------------------------------------------------------------- % +% redefine title to accept a short tile (like chapter, etc..) +\newcommand*{\@shorttitle}{\@empty} +\renewcommand{\title}[2][]{ + \gdef\@title{#2} + \gdef\@shorttitle{#1} +} \newcommand*{\@matrikelnr}{} \newcommand{\matrikelnr}[1]{\gdef\@matrikelnr{#1}} \newcommand*{\@professor}{} @@ -169,10 +175,18 @@ %<*article|report> %% header and footer \newpagestyle{HsHheadings}{ - {\parbox{\sls@headwidth}{\LaTeXraggedright\@title}} - {\parbox{\sls@headwidth}{\LaTeXraggedleft\leftmark}} { - \parbox[b]{.45\sls@headwidth}{\LaTeXraggedright\@title}% + \parbox[b]{\sls@headwidth}{ + \LaTeXraggedright + \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + }% + } + {\parbox[b]{\sls@headwidth}{\LaTeXraggedleft\leftmark}} + { + \parbox[b]{.45\sls@headwidth}{ + \LaTeXraggedright + \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + }% \hfill \parbox[b]{.45\sls@headwidth}{\LaTeXraggedleft\headmark}% } diff --git a/README.md b/README.md index 6e84a13c6d8e5bdc46b495c3df8ce47c3e50d0db..2477cc9a4454759ed77756d8ecbbbf24331975da 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,8 @@ You can use the following macros to define the different information presented o comma-seperated list, if more than one author is present. - `\titlehead` is for a small line left of the logo. This is usually the department or division. May be empty - `\subject` is for a broad description of what your file is. "Laborbericht" for example. Can be empty. -- `\title` is quite obvious. The only one that must be present. +- `\title` is quite obvious. The only one that must be present. I additionally accept an optional parameter which will be treated as a short form of + the title and used in the header (this makes sense if your title is very long and fills your header too much) - `\subtitle` is a smaller second line under the title. Can be empty - `\date` is the date of your project. You can use a custom one, but if you don't set it, the current date at compile time will be used. - `\professor` a new macro do define your professors name, if needed. diff --git a/src/HsH-article.cls b/src/HsH-article.cls index af0ce27accd70e7d8891cf9b94ab9ad9164ad108..af8be928a1b28040574da73f9e4f06cdca215eb7 100644 --- a/src/HsH-article.cls +++ b/src/HsH-article.cls @@ -101,6 +101,11 @@ \PassOptionsToPackage{european,EFvoltages,straightvoltages,betterproportions}{circuitikz} %% title matters ---------------------------------------------------------------------------------- +\newcommand*{\@shorttitle}{\@empty} +\renewcommand{\title}[2][]{ + \gdef\@title{#2} + \gdef\@shorttitle{#1} +} \newcommand*{\@matrikelnr}{} \newcommand{\matrikelnr}[1]{\gdef\@matrikelnr{#1}} \newcommand*{\@professor}{} @@ -120,10 +125,18 @@ %% header and footer \newpagestyle{HsHheadings}{ - {\parbox{\sls@headwidth}{\LaTeXraggedright\@title}} - {\parbox{\sls@headwidth}{\LaTeXraggedleft\leftmark}} { - \parbox[b]{.45\sls@headwidth}{\LaTeXraggedright\@title}% + \parbox[b]{\sls@headwidth}{ + \LaTeXraggedright + \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + }% + } + {\parbox[b]{\sls@headwidth}{\LaTeXraggedleft\leftmark}} + { + \parbox[b]{.45\sls@headwidth}{ + \LaTeXraggedright + \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + }% \hfill \parbox[b]{.45\sls@headwidth}{\LaTeXraggedleft\headmark}% } diff --git a/src/HsH-report.cls b/src/HsH-report.cls index f37c7d9673611274efaaae586c50af05a159c2e4..ac8a96207059ad94f12c68ef0f531e5871d107d8 100644 --- a/src/HsH-report.cls +++ b/src/HsH-report.cls @@ -101,6 +101,11 @@ \PassOptionsToPackage{european,EFvoltages,straightvoltages,betterproportions}{circuitikz} %% title matters ---------------------------------------------------------------------------------- +\newcommand*{\@shorttitle}{\@empty} +\renewcommand{\title}[2][]{ + \gdef\@title{#2} + \gdef\@shorttitle{#1} +} \newcommand*{\@matrikelnr}{} \newcommand{\matrikelnr}[1]{\gdef\@matrikelnr{#1}} \newcommand*{\@professor}{} @@ -120,10 +125,18 @@ %% header and footer \newpagestyle{HsHheadings}{ - {\parbox{\sls@headwidth}{\LaTeXraggedright\@title}} - {\parbox{\sls@headwidth}{\LaTeXraggedleft\leftmark}} { - \parbox[b]{.45\sls@headwidth}{\LaTeXraggedright\@title}% + \parbox[b]{\sls@headwidth}{ + \LaTeXraggedright + \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + }% + } + {\parbox[b]{\sls@headwidth}{\LaTeXraggedleft\leftmark}} + { + \parbox[b]{.45\sls@headwidth}{ + \LaTeXraggedright + \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + }% \hfill \parbox[b]{.45\sls@headwidth}{\LaTeXraggedleft\headmark}% } diff --git a/test.pdf b/test.pdf index 8f5b8883e0ffdd130cba7763a2498dc9f6b7adb7..b9e4e8c9d6eb2d9b624a1e7b368ea5c20ad43b1a 100644 Binary files a/test.pdf and b/test.pdf differ diff --git a/test.tex b/test.tex index b47e105f56b2df4c903103b02443cb7900a1a30d..34b7ff10b03bba083e371fbe6236f4095368c4e0 100644 --- a/test.tex +++ b/test.tex @@ -18,7 +18,7 @@ } \titlehead{titlehead} \subject{Subject} -\title{long and elaborate title that just goes on and on witout stopping} +\title[short title]{long and elaborate title that just goes on and on witout stopping} \subtitle{Subtitle} \date{\today} \professor{Professor} @@ -49,6 +49,8 @@ \caption{test} \end{figure} + title test: \ifx\@shorttitle\@empty\@title\else\@shorttitle\fi + noch ein test \normalsubscripts$R_t$ \upsubscripts$R_t$ mit einheit: $R=200\,\mohm+ \SI{0.34567453}{\volt\per\metre}$