页眉中已加星标的章节?(scrbook)

页眉中已加星标的章节?(scrbook)

是否有可能在 scrbook 的标题中显示未编号的章节(带星号的章节)?

以下是一个小代码示例:

\documentclass[oneside,openright,BCOR=5mm,paper=a4,fontsize=11pt]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[automark]{scrpage2}
\usepackage{xcolor}

\usepackage{geometry}
\geometry{a4paper, top=35mm, left=30mm, right=30mm, bottom=25mm, headsep=15mm, footskip=12mm}

\usepackage[demo]{graphicx}
\usepackage{textpos}
\usepackage{blindtext}
\usepackage{lipsum}
\usepackage{titlesec}

\usepackage{mparhack}

\titleformat{\chapter}[hang]{}{\parbox{1.5cm}{\thechapter}}{0pt}{}{}
\titleformat{\section}[hang]{}{\parbox{1.5cm}{\thesection}}{0pt}{}{}
\titleformat{\subsection}[hang]{}{\parbox{1.5cm}{\thesubsection}}{0pt}{}{}
\titleformat{\subsubsection}[hang]{}{\parbox{1.5cm}{\thesubsubsection}}{0pt}{}{}

\begin{document}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead[\headmark]{\headmark}

\tableofcontents

\chapter*{The concerning one ...}
\lipsum[1-6]
\chapter{Chapter 1}
\lipsum[7]
\section{Section 1}
\lipsum[8-10]
\chapter{Chapter 2}
\lipsum[11]

\end{document}

带星号的章节也应该像无星号的章节一样出现在标题中。(但它们不应该出现在目录中...)- 我希望这在某种程度上是可能的。(我还使用 titlesec 包来格式化章节... 我希望这不会给我的主要问题带来“额外的困难”...)。

提前谢谢你! eniem

编辑:这是我使用的章节/部分标题:

\newlength\widestnum
\setlength\widestnum{4em}
\titleformat{\chapter}[hang]
  {\normalfont\bfseries\Large}
  {}
  {0em}
  {%
    \makebox[\linewidth]{%
      \colorbox{gray!20}{%
        \parbox{\textwidth}{%
          \parbox[t]{\widestnum}{\thechapter}%
          \parbox[t]{\dimexpr\textwidth-\widestnum\relax}{#1}%
        }%
      }%
    }%
  }
\titleformat{\section}[hang]
  {\normalfont\bfseries}
  {}
  {0em}
  {%
    \makebox[\linewidth]{%
      \fbox{%
        \parbox{\textwidth}{%
          \parbox[t]{\widestnum}{\thesection}%
          \parbox[t]{\dimexpr\textwidth-\widestnum\relax}{#1}%
        }%
      }%
    }%
  }
\titleformat{\subsection}[hang]
  {\normalfont\bfseries}
  {}
  {0em}
  {%
    %%\makebox[\linewidth]{%
    %%  \fbox{%
        \parbox{\textwidth}{%
          \parbox[t]{\widestnum}{\thesubsection}%
          \parbox[t]{\dimexpr\textwidth-\widestnum\relax}{#1}%
        }%
    %%  }%
    %%}%
  }
\titleformat{\subsubsection}[hang]
  {\normalfont\bfseries}
  {}
  {0em}
  {%
    %%\makebox[\linewidth]{%
    %%  \fbox{%
        \parbox{\textwidth}{%
          \parbox[t]{\widestnum}{\thesubsubsection}%
          \parbox[t]{\dimexpr\textwidth-\widestnum\relax}{#1}%
        }%
    %%  }%
    %%}%
  }   
\titleformat{name=\chapter,numberless}[hang]
  {\bfseries\Large}
  {}
  {0em}
  {%
%    \makebox[\linewidth]{%
 %     \colorbox{gray!20}{%
        \parbox{\textwidth}{#1}%
  %    }%
  %  }%
  }
\titleformat{name=\section,numberless}[hang]
  {\normalfont\bfseries}
  {}
  {0em}
  {%
    \makebox[\linewidth]{%
      \fbox{%
        \parbox{\textwidth}{#1}%
      }%
    }%
  }
\titleformat{name=\subsection,numberless}[hang]
  {\normalfont\bfseries}
  {}
  {0em}
  {%
    \makebox[\linewidth]{%
      \fbox{%
        \parbox{\textwidth}{#1}%
      }%
    }%
  }

\titlespacing*{\chapter}
  {0pt}{0pt}{20pt}

答案1

您可以通过设置类选项来启用可选部分参数的扩展解释

headings=optiontoheadandtoc

然后简单使用

\addchap[tocentry={}]{The concerning one ...}

要得到

在此处输入图片描述

\documentclass[
  oneside,
  BCOR=5mm,
  headings=optiontoheadandtoc
]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[automark]{scrpage2}
\usepackage{xcolor}

\usepackage{geometry}
\geometry{a4paper, top=35mm, left=30mm, right=30mm, bottom=25mm, headsep=15mm, footskip=12mm}

\usepackage[demo]{graphicx}
\usepackage{textpos}
\usepackage{blindtext}

\usepackage{mparhack}

\usepackage{titlesec}
\titleformat{\chapter}[hang]{}{\parbox{1.5cm}{\thechapter}}{0pt}{}{}
\titleformat{\section}[hang]{}{\parbox{1.5cm}{\thesection}}{0pt}{}{}
\titleformat{\subsection}[hang]{}{\parbox{1.5cm}{\thesubsection}}{0pt}{}{}
\titleformat{\subsubsection}[hang]{}{\parbox{1.5cm}{\thesubsubsection}}{0pt}{}{}


\begin{document}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead[\headmark]{\headmark}

\tableofcontents

\addchap[tocentry={}]{The concerning one ...}
\blindtext[10]
\chapter[Chapter 1]{Chapter 1}
\blindtext[10]
\blinddocument

\end{document}

由于使用了软件包,我收到了警告titlesec,但代码对我来说是可行的。不过,您也可以在没有的情况下格式化章节titlesec。尝试

\setkomafont{disposition}{\normalfont}
\setkomafont{chapter}{\normalfont}
\setkomafont{section}{\normalfont}
\setkomafont{subsection}{\normalfont}
\renewcommand\chapterformat{\makebox[1.5cm][l]{\thechapter\autodot}}
%%% the following code needs version 3.17 or newer
  \renewcommand\sectionformat{\makebox[1.5cm][l]{\thesection\autodot}}
  \renewcommand\subsectionformat{\makebox[1.5cm][l]{\thesubsection\autodot}}
  \renewcommand\subsubsectionformat{\makebox[1.5cm][l]{\thesubsubsection\autodot}}
%%% the following code works with 3.16 or older
  %\renewcommand\othersectionlevelsformat[3]{\makebox[1.5cm][l]{#3\autodot}}

代替

\usepackage{titlesec}
\titleformat{\chapter}[hang]{}{\parbox{1.5cm}{\thechapter}}{0pt}{}{}
\titleformat{\section}[hang]{}{\parbox{1.5cm}{\thesection}}{0pt}{}{}
\titleformat{\subsection}[hang]{}{\parbox{1.5cm}{\thesubsection}}{0pt}{}{}
\titleformat{\subsubsection}[hang]{}{\parbox{1.5cm}{\thesubsubsection}}{0pt}{}{}

答案2

这是 的解决方案 titleps。用这个包重新定义 pagestyles 会与 冲突scrpage2,所以我删除了它,因为我删除了代码中未使用的包。

\documentclass[oneside,openright,paper=a4,BCOR=5mm,fontsize=11pt]{scrbook}%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}

\usepackage{geometry}
\geometry{a4paper, top=35mm, left=30mm, right=30mm, bottom=25mm, headsep=15mm, footskip=12mm, bindingoffset = 5mm}

\usepackage[demo]{graphicx}
\usepackage{blindtext}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}

\titleformat{\chapter}[hang]{}{\parbox{1.5cm}{\thechapter}}{0pt}{#1}%
\titleformat{name = \chapter, numberless}[hang]{}{}{0pt}{\chaptermark{#1}#1}%
\titleformat{\section}[hang]{}{\parbox{1.5cm}{\thesection}}{0pt}{}{}
\titleformat{\subsection}[hang]{}{\parbox{1.5cm}{\thesubsection}}{0pt}{}{}
\titleformat{\subsubsection}[hang]{}{\parbox{1.5cm}{\thesubsubsection}}{0pt}{}{}

\renewpagestyle{plain}{%
\sethead[\slshape\chaptertitle][][]{}{}{\slshape\chaptertitle}
\setfoot{}{}{}
}
\pagestyle{plain}

\begin{document}
%\pagestyle{scrheadings}
%\clearscrheadfoot
%\ohead[\headmark]{\headmark}

\tableofcontents

\chapter*{The concerning one ...}
\lipsum[1-6]
\chapter{Chapter 1}
\lipsum[7]
\section{Section 1}
\lipsum[8-12]
\chapter{Chapter 2}
\lipsum[13-18]

\end{document} 

在此处输入图片描述

相关内容