<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to HowTo_PagenumberWithDash</title><link>https://sourceforge.net/p/koma-script/wiki-en/HowTo_PagenumberWithDash/</link><description>Recent changes to HowTo_PagenumberWithDash</description><atom:link href="https://sourceforge.net/p/koma-script/wiki-en/HowTo_PagenumberWithDash/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 27 May 2025 08:01:55 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/koma-script/wiki-en/HowTo_PagenumberWithDash/feed" rel="self" type="application/rss+xml"/><item><title>HowTo_PagenumberWithDash modified by Markus Kohm</title><link>https://sourceforge.net/p/koma-script/wiki-en/HowTo_PagenumberWithDash/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="how-to-add-horizontal-lines-to-page-numbers-in-the-header-or-footer"&gt;How to add horizontal lines to page numbers in the header or footer&lt;/h1&gt;
&lt;p&gt;The desire to add horizontal lines to the page number in the header or footer and display it as “- 1 -”, “– 1 –” or “— 1 —”, for example, is not uncommon, although such a display is often perceived as old-fashioned in scientific documents. One possibility would of course be to redefine the &lt;code&gt;plain&lt;/code&gt; and &lt;code&gt;headings&lt;/code&gt; page styles (using the &lt;code&gt;scrlayer&lt;/code&gt; or &lt;code&gt;scrlayer-scrpage&lt;/code&gt; package) so that the dashes are directly part of the page style. Depending on the document setting—for example &lt;code&gt;twoside&lt;/code&gt; or not—the page number is output at a different position and depending on this either the &lt;code&gt;scrlayer-scrpage&lt;/code&gt; instruction &lt;code&gt;\cfoot&lt;/code&gt; resp. &lt;code&gt;\cfoot*&lt;/code&gt; or &lt;code&gt;\ofoot&lt;/code&gt; resp. &lt;code&gt;\ofoot*&lt;/code&gt; should be used. The same applies when using other page style packages such as &lt;code&gt;scrlayer-fancyhdr&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With the KOMA script classes, it is easier to achieve the desired result by redefining &lt;code&gt;\pagemark&lt;/code&gt;. By default, the definition is&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\DeclareRubustCommand&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\pagemark&lt;/span&gt;&lt;span class="nb"&gt;}{{&lt;/span&gt;&lt;span class="k"&gt;\usekomafont&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;pagenumber&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\thepage&lt;/span&gt;&lt;span class="nb"&gt;}}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The desired dashes can simply be inserted, for example by adding&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\DeclareRobustCommand&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\pagemark&lt;/span&gt;&lt;span class="nb"&gt;}{{&lt;/span&gt;&lt;span class="k"&gt;\usekomafont&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;pagenumber&lt;span class="nb"&gt;}{&lt;/span&gt;--~&lt;span class="k"&gt;\thepage&lt;/span&gt;~--&lt;span class="nb"&gt;}}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;or&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\DeclareRobustCommand&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\pagemark&lt;/span&gt;&lt;span class="nb"&gt;}{&lt;/span&gt;--~&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\usekomafont&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;pagenumber&lt;span class="nb"&gt;}{&lt;/span&gt;&lt;span class="k"&gt;\thepage&lt;/span&gt;&lt;span class="nb"&gt;}}&lt;/span&gt;~--&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to the document preamble.&lt;/p&gt;
&lt;p&gt;The difference between the two redefinitions is that in the first case, the font for the element &lt;code&gt;pagenumber&lt;/code&gt; also affects the dashes, whereas in the second case, only the page number is set in the font of this element. As a rule, you will therefore want to use the first version.&lt;/p&gt;
&lt;p&gt;As the &lt;code&gt;scrlayer&lt;/code&gt; package used by &lt;code&gt;scrlayer-scrpage&lt;/code&gt; also provides &lt;code&gt;\pagemark&lt;/code&gt;, this solution can also be used with the standard classes as soon as &lt;code&gt;scrlayer-scrpage&lt;/code&gt; (or &lt;code&gt;scrlayer&lt;/code&gt;) is loaded. When using &lt;code&gt;\DeclareRobustCommand&lt;/code&gt;, it does not matter whether the redefinition takes place before or after loading &lt;code&gt;scrlayer-scrpage&lt;/code&gt;. If you use &lt;code&gt;\RenewDocumentCommand&lt;/code&gt; instead, for example in the form:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;\RenewDocumantCommand&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="k"&gt;\pagemark&lt;/span&gt;&lt;span class="nb"&gt;}{}{{&lt;/span&gt;&lt;span class="k"&gt;\usekomafont&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;pagenumber&lt;span class="nb"&gt;}{&lt;/span&gt;--~&lt;span class="k"&gt;\thepage&lt;/span&gt;~--&lt;span class="nb"&gt;}}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;this can also be done together with a KOMA script class either before or after loading &lt;code&gt;scrlayer-scrpage&lt;/code&gt;. With other classes, however, the instruction should usually be &lt;em&gt;after&lt;/em&gt; loading &lt;code&gt;scrlayer-scrpage&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The use of &lt;code&gt;\renewcommand&lt;/code&gt; or &lt;code&gt;\renewcommand*&lt;/code&gt; to redefine &lt;code&gt;\pagemark&lt;/code&gt; is not recommended, as the original definition in &lt;code&gt;scrlayer&lt;/code&gt; is also robust.&lt;/p&gt;
&lt;h3 id="notes"&gt;Notes:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Some people on the Internet suggest redefining the instruction &lt;code&gt;\thepage&lt;/code&gt; instead of &lt;code&gt;\pagemark&lt;/code&gt;. However, this is not recommended, as otherwise the dashes would also be used in directory entries, for example in the table of contents, list of figures or list of tables or in page references with &lt;code&gt;\pageref&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Instead of simple dashes with &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;--&lt;/code&gt; or &lt;code&gt;---&lt;/code&gt;, you can of course also use more complex shapes and ornaments, for example with the help of &lt;a class="" href="https://www.ctan.org/pkg/tikz" rel="nofollow"&gt;TikZ&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Markus Kohm</dc:creator><pubDate>Tue, 27 May 2025 08:01:55 -0000</pubDate><guid>https://sourceforge.net93db8e2dfe7e38e49df7bb074783afae52308aad</guid></item></channel></rss>