2

I would like to redefine the \@maketitle command of scrbook. For this reason I need the source code of scrbook class. I don't have Miktex or Texlive installed on my computer, I use only sharelatex.

I know that it is possible to use \show or \meaning to get the definitions, but I need an output showing also the indentations.

BxlAdil
  • 77
  • 5
  • A good start: https://ctan.org/pkg/scrbook?lang=en. At that page there is a zip file download. In the zip file: tex\latex\koma-script\scrbook.cls. V3.24 confirmed. – Steven B. Segletes Feb 08 '18 at 15:40
  • There really is no need to develop a new documentclass for a thesis. If you want to create a titlepag of your own, look at http://tex.stackexchange.com/questions/209993/how-to-customize-my-titlepage/210280#210280 and https://en.wikibooks.org/wiki/LaTeX/Title_Creation. – Johannes_B Feb 10 '18 at 13:43

3 Answers3

3

As noted in my comment,

A good source and always my initial go-to place is CTAN. For scrbook, try ctan.org/pkg/scrbook?lang=en. At that page there is a TDS archive, koma-script.tds.zip file download. In the zip file subdirectory, you will find: tex\latex\koma-script\scrbook.cls. V3.24 confirmed.

The definition of \@maketitle is

\newcommand*{\@maketitle}{%
  \global\@topnum=\z@
  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
  \ifx\@titlehead\@empty \else
    \begin{minipage}[t]{\textwidth}
      \usekomafont{titlehead}{\@titlehead\par}%
    \end{minipage}\par
  \fi
  \null
  \vskip 2em%
  \begin{center}%
    \ifx\@subject\@empty \else
      {\usekomafont{subject}{\@subject \par}}%
      \vskip 1.5em
    \fi
    {\usekomafont{title}{\huge \@title \par}}%
    \vskip .5em
    {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
    \vskip 1em
    {%
      \usekomafont{author}{%
        \lineskip .5em%
        \begin{tabular}[t]{c}
          \@author
        \end{tabular}\par
      }%
    }%
    \vskip 1em%
    {\usekomafont{date}{\@date \par}}%
    \vskip \z@ \@plus 1em
    {\usekomafont{publishers}{\@publishers \par}}%
    \ifx\@dedication\@empty \else
      \vskip 2em
      {\usekomafont{dedication}{\@dedication \par}}%
    \fi
  \end{center}%
  \par
  \vskip 2em
}%
  • One more question, how to redefine it ? \renewcommand*@maketitle or \def@maketitle seem not to work – BxlAdil Feb 08 '18 at 17:22
  • @BxlAdil The @ character is a special charcter. In normal documents, it is considered an "other" symbol and cannot be part of a macro name. In classes and styles, it is considered a "letter" and can be part of a macro name. To overcome this limitation in your document, there is \makeatletter and \makeatother, which change the \catcode of @ to 11 and 12, respectively. Thus, place \makeatletter before your redefinition of \@maketitle and \makeatother after its redefinition. – Steven B. Segletes Feb 08 '18 at 17:37
  • @BxlAdil See https://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do – Steven B. Segletes Feb 08 '18 at 17:38
  • 1
    Actually I used many times these commands. But still I don't know why it is not working, please check this MWE in overleaf https://www.overleaf.com/13690295wtvwgtxrvkwm#/52962103/ normaly the title should be colored in red and a smal word must be added in the bottom. – BxlAdil Feb 08 '18 at 17:48
  • @BxlAdil No reason jumps to mind as to why the change does not take. I would say, however, that it is a large complex class. – Steven B. Segletes Feb 08 '18 at 18:01
  • @BxlAdil It would appear, with your MWE, that \if@titlepage is set true, and so that block of code executed by \maketitle bypasses the call the \@maketitle. – Steven B. Segletes Feb 08 '18 at 18:03
  • @BxlAdil ...so look for the part of the \maketitle definition that between the \begin and \end of the environment {titlepage} – Steven B. Segletes Feb 08 '18 at 18:07
2

As you use ShareLaTeX, you must patch the scrbook.cls provided by ShareLaTeX.

Compile the following document on ShareLaTeX to get the correct source (96 pages with colors):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
%\usepackage[margin=1cm]{geometry}
\usepackage{fancyvrb}
\usepackage{listings}
\usepackage{accsupp}
\newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}

\title{\texttt{scrbook.cls} listing on ShareLaTeX}
\author{Paul Gaborit}
\date{February 2018}
\lstdefinestyle{latex}{
  fancyvrb=true,
  language=[LaTeX]TeX,
  basicstyle=\ttfamily\scriptsize,
  keywordstyle=\color{blue}\bfseries,
  commentstyle=\color{red!50!black}\itshape,
  stringstyle=\ttfamily\color{green!50!black},
  numbers=left,
  numberstyle=\tiny\color{gray}\noaccsupp,
  stepnumber=1,
  numbersep=5pt,
  showspaces=false,
  showstringspaces=false,
  %backgroundcolor=\color{white},
  frame=leftline,
  rulecolor=\color{gray!30},
  fontadjust=true,
  aboveskip=0pt,
  belowskip=0pt,
  emphstyle=\color{red},
  keepspaces=true,
  flexiblecolumns=true,
  xleftmargin=1.2em,
}


\begin{document}

\maketitle

\lstinputlisting[style=latex]{scrbook.cls}
\end{document}
Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
  • +1, I was going to suggest this excellent idea. Basically if TeX can use scrbook then it can find it, so you can just use TeX to typeset it. (BTW your code compiles for me on ShareLaTeX only if I replace /usr/local/texlive/2017/texmf-dist/tex/latex/koma-script/scrbook.cls with just scrbook.cls.) – ShreevatsaR Feb 08 '18 at 18:34
  • @ShreevatsaR "Your wishes are orders" (I removed the path). – Paul Gaborit Feb 08 '18 at 21:41
0

You asked the wrong question, which happens quite frequently on tex.sx. You are (probably) a kind of newbie to LaTeX and you'd like to do something with the title of your article / report / book.

Please ask a new question about what you want to achieve in the end.

Hacking into a mainline package like the KOMA-script bundle probably is neither worth the effort, nor the way to go. Many many layouts can be realised without that. Just ask an add an MWE.

Keks Dose
  • 30,892
  • @ Keks Dose I started to use latex in 2011. – BxlAdil Feb 08 '18 at 17:53
  • And I'm writing my own document class for my thesis – BxlAdil Feb 08 '18 at 17:55
  • @BxlAdil Well, after reading this and the other answer and comments, I stick to my advise. Usually a thesis is challenging enough without maintaining a documentclass based on KOMA-script. Either a thesis, or a documentclass. Good luck! – Keks Dose Feb 08 '18 at 20:11