KOMA-Script scrbook: chapter titles right-aligned, between lines, chapter number on top in words

Rich Shepard rshepard at appl-ecosys.com
Thu Jul 13 23:40:00 UTC 2023


I'm trying to change the KOMA-Script book chapter headings so the heading is
right-aligned, between two horizontal rules, and the chapter title is above
the top rule as in the memoir class demo chapter head (attached.)

I had found code on the KOMA-Script wiki to place chapter headings between
two lines and right-align it, but lost the code for the latter. A minimal
working example file is attached. The chapter headings are between two
rules, but still left-aligned. The last two lines of the preamble show what I
tried from StackExchange threads; neither works for me and I've not found
code that puts the header number in lower-case words centered above the top
rule.

Pointers to solutions needed.

TIA,

Rich
-------------- next part --------------
#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass scrbook
\begin_preamble
\date{}
\usepackage{mathpazo,amssymb}
\usepackage{graphicx,relsize}
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{lipsum}
%% Add clines above and below chaper headings
\usepackage{xpatch}
\xapptocmd{\chapterheadstartvskip}{%
  {%
     \setlength{\parskip}{0pt}%
     \setlength{\parfillskip}{0pt plus 1fil}%
      \noindent\rule[.3\baselineskip]{\linewidth}{1pt}\par
   }\nobreak
}{%
  \typeout{Horizontal line before chapter heading added.}%
}{%
  \errmessage{Failed to patch \string\chapterheadstartvskip}%
}%
\xpretocmd{\chapterheadendvskip}{%
  {%
     \setlength{\parskip}{0pt}%
     \setlength{\parfillskip}{0pt plus 1fil}%
      \noindent\rule[-.3\baselineskip]{\linewidth}{1pt}\par
   }\nobreak
}{%
  \typeout{Horizontal line after chapter heading added.}%
}{%
  \errmessage{Failed to patch \string\chapterheadendvskip}%
}%
%% Align chapter heading on right
%\let\raggedchapter\raggedrightrenewcommand*{\raggedsec
%%\renewcommand*{\raggedchapter}{\raggedright}
\end_preamble
\use_default_options false
\begin_modules
natbibapa
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding default
\fontencoding global
\font_roman "palatino" "default"
\font_sans "avant" "default"
\font_typewriter "courier" "default"
\font_math "auto" "auto"
\font_default_family rmdefault
\use_non_tex_fonts false
\font_sc true
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures false
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize custom
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 0
\use_package esint 0
\use_package mathdots 1
\use_package mathtools 0
\use_package mhchem 1
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine natbib
\cite_engine_type authoryear
\biblio_style authordate4
\biblio_options maxcitenames=1,maxbibnames=99,uniquename=false,uniquelist=false
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\paperwidth 6in
\paperheight 9in
\leftmargin 0.75in
\topmargin 0.9in
\rightmargin 0.75in
\bottommargin 0.9in
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 2
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
Change Chapter Headings to Right Aligned and Between Lines
\end_layout

\begin_layout Author
I.M.
 Writing
\end_layout

\begin_layout Chapter
First Chapter
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
lipsum{2-4}
\end_layout

\end_inset


\end_layout

\begin_layout Chapter
Another Chapter
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
lipsum{99-102}
\end_layout

\end_inset


\end_layout

\end_body
\end_document
-------------- next part --------------
A non-text attachment was scrubbed...
Name: memoir-chapterhead-demo.png
Type: image/png
Size: 46500 bytes
Desc: 
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20230713/54820863/attachment-0001.png>


More information about the lyx-users mailing list