0

I have two questions. First I would like to add subsection to the tableofcontent of my document to structure a little bit the toc without repeating the subsection in the docoment. And I already found out that this code:

\documentclass[]{scrartcl}
\usepackage{cook}
\usepackage[T1]{fontenc}
\usepackage{wallpaper}
\usepackage{longtable}

% NEW CODE FOR THE PROBLEM!!!
\newcommand{\fakesubsection}[1]{%
  \subsectionmark{#1}% Add subsection mark (header)
  \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}% Add subsection to ToC
  % Add more content here, if needed.
}
\tableofcontents


\section{Header A}
\fakesubsection{subsection}
\input{site1.tex}
\input{site2.tex}
\input{site3.tex}

\section{Header B}
\input{site1.tex}
\input{site2.tex}
\input{site3.tex}

\end{document}

works for me but now I would like to suppress the numbering of the subsections and I didn't find a solution for this problem that's why I am hopping someone here can give me a hint how I can do this.

My second question can I use something like conditional meshed for the text so that every entry that start after a section a meshed up 2 cm and every entry that starts after a subsection 4 cm so that I get a structure like

Header AAA
  Subsection aaa
    Site 1
    Site 2
    Site 3

Header BBB
  Site 4
  Site 5
  Site 6

I hope my explation is good enough to understand what I am looking for and of course I would very thankful for every hint. best regards Dan

  • Welcome to TeX.SX! Please do not post two different (and apparently totally unrelated) issues in one question. – user31729 Jul 3 '16 at 10:24
  • If you want to remove the numbering, just remove the \protect\numberline{\thesubsection} code snippet in \addcontentsline – user31729 Jul 3 '16 at 10:29
  • Crosspost: mrunix.de/forums/showthread.php?77109 – esdd Jul 4 '16 at 11:09
3

scrartcl is a KOMA-Script class. So you can use

\newcommand{\fakesubsection}[1]{%
  \subsectionmark{#1}% add subsection mark (header)
  \addsubsectiontocentry{}{#1}% add as subsection to ToC
}

to add this text as subsection without number to the table of contents.


Update using scrreprt which provides chapters (based on the MWE and the informations in this post on mrunix.de)

\documentclass[]{scrreprt}[2016/05/10]

% Inputencoding hier selbst festlegen
\PreventPackageFromLoading{inputenc,fixltx2e}
\usepackage{cook}% see https://sourceforge.net/projects/chilicookbook/
\UnPreventPackageFromLoading{inputenc}
\usepackage[utf8]{inputenc}

\usepackage{longtable}

\recipecolor{C20E0F}

\setcounter{secnumdepth}{-1}
\setcounter{tocdepth}{\subsectiontocdepth}

\RedeclareSectionCommand[%
  beforeskip=-2cm,%
  font=\rmfamily\Huge\color{darkred},%
  tocentryformat=\sffamily\Large\textbf%
]{chapter}
\renewcommand\raggedchapter{\centering}

\RedeclareSectionCommand[%
  tocbeforeskip=5pt plus .2pt,%
  toclinefill=\hfill,%
  tocpagenumberformat=\blank,%
  tocentryformat=\textbf%
]{section}
\newcommand\blank[1]{}

\newcommand{\fakesection}[1]{%
  \sectionmark{#1}% Add subsection mark (header)
  \addtocentrydefault{section}{}{#1}
}

\begin{document}
\tableofcontents
\chapter{Hauptgericht}
\fakesection{Deutsche Küche}
\begin{recipe}[]{Bandnudeln mit Lachs}{Quelle?}{}
  \ingredient{Salz, Pfeffer}
  \ingredient{Bandnudeln}
  \step
  Ins Restaurant gehen und kaufen, essen und freuen
\end{recipe}

\begin{recipe}[]{Apfelpfannkuchen}{Quelle?}{}
  \ingredient{2 Äpfel}
  \ingredient{Prise Salz}
  \step
  Chips sind auch lecker
\end{recipe}

\chapter{Gebäck}
\begin{recipe}[]{Apfel-Zimt-Muffins}{Quelle?}{}
  \ingredient{120g Vollkorn-Weizenmehl}
  \ingredient{250g Äpfel}
  \step
  Äpfel sind auch so gesund
\end{recipe}

\begin{recipe}[]{Apfelkuchen mit Mandel-Zimt Streuseln}{}
  \par
  \ingredient{1 Päckchen Vanillezucker}
  \ingredient{2 Eier}
  \ingredient{Zimt}
  \ingredient{Salz}
  \step
  Kekse kann man auch kaufen
\end{recipe}
\end{document}

enter image description here

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.