編集

編集

新しいタイプの見出しを作成したいと思います。見出しは次のようになります。ここに画像の説明を入力してください

ヘッダーの名前は「Myheader」にする必要があります。現在、私は次のように問題を解決しました:

\makeatletter
\newcommand{\Myheader}{\subsubsection}
\makeatother
\titlespacing*{\subsubsection}{0cm}{0cm}{2pt}%pbk
\titleformat{\subsubsection}[display]{\Huge\filleft\scshape}{ \normalfont\bf\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]

ヘッダーをまだ使用できるようにしたいので\subsubsection、この解決策は受け入れられません。コードの最小限の例は次のとおりです。

\documentclass[10pt,a4paper,oneside]{article}
\usepackage[danish,english]{babel}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\makeatletter
\newcommand{\Myheader}{\subsubsection}
\makeatother
\titlespacing*{\subsubsection}{0cm}{0cm}{2pt}%pbk
\titleformat{\subsubsection}[display]{\Huge\filleft\scshape}{ \normalfont\bf\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]
\begin{document}
\Myheader{The first appendix}
\end{document}

これを解決する方法をご存知ですか?

答え1

付録を開始するために発行されたコマンドにパッチを適用して、\sectionその時点以降、つまり付録に対してのみ正しい結果が生成されるようにすることができます。これにより、付録がセクション階層内の適切なレベルに配置され (ToC やブックマークなど)、コードが最大限に柔軟になります (気が変わった場合は、パッチを削除するだけです)。

例えば:

\documentclass[10pt,a4paper,oneside]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec,etoolbox}
\usepackage{kantlipsum}
\apptocmd\appendix{%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}]
}{\typeout{Appendices title formatting successfully patched. Expect the expected.}}{\typeout{Appendices title formatting could not be patched. Unexpected results paradoxically to be expected.}}
\begin{document}
\section{A section}
\kant[1]
\section{Another section}
\kant[2]
\appendix
\section{The first appendix}
\kant[3]
\end{document}

パッチを当てた付録

編集

コメントで、が発行された\section後のページで空のヘッダーを取得するためにこれを変更するにはどうすればよいですかと質問されました。あなたのコメントから、 を使用していると推測できます。他の場所でヘッダーに現在使用しているコードを知らないと、これを行うための最良の方法を特定することは困難ですが、適度に標準的なものがあれば、これで機能するはずです。\appendixfancyhdr

\documentclass[10pt,a4paper,oneside]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{titlesec,etoolbox,fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhf[lh]{\leftmark}
\fancyhf[rh]{\thepage}
\fancypagestyle{ancy}{%
  \fancyhf[h]{}%
  \renewcommand\headrulewidth{0pt}%
}
\usepackage{kantlipsum}
\apptocmd\appendix{%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}\thispagestyle{ancy}]
}{\typeout{Appendices title formatting successfully patched. Expect the expected.}}{\typeout{Appendices title formatting could not be patched. Unexpected results paradoxically to be expected.}}
\begin{document}
\section{A section}
\kant[1-4]
\section{Another section}
\kant[5]
\appendix
\section{The first appendix}
\kant[6-8]
\end{document}

付録の新しいセクションにヘッダーがない

これは説明の文字通りの解釈であり、あなたが望むものであるかどうかはわかりません。特に:

  • \section; は、ページに ;の前にも;\appendixが含まれている場合でも、現在のページのヘッダーを空にします。\section\appendix
  • 以降のページには、\appendixが含まれていない場合は標準ヘッダーが含まれます\section

ヘッダーをまったく必要としない場合は、次のように\appendixします。

\apptocmd\appendix{%
  \pagestyle{ancy}%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}\thispagestyle{ancy}]
}{\typeout{Appendices title formatting successfully patched. Expect the expected.}}{\typeout{Appendices title formatting could not be patched. Unexpected results paradoxically to be expected.}}

付録にヘッダーが全くない

ここでの他の可能性はより複雑なので、必要な場合にのみそれらについて検討します。その場合、そのfancyhdr時点ではおそらく最も簡単に移行できるため、ヘッダーの現在のコードから作業します。titleps補完的でtitlesec、ここではうまく機能します。

編集 編集

同様の方法でパッチを当てるというご質問への回答です\tableofcontentsが、確かにこれを行うことができます。ただし、正確にすべてがどのように見えるかについては少し混乱しており、投稿されたコードの目的を正確に理解することはできませんでした。(ただし、明示的なページ区切りとページ番号は、ページ スタイルの定義に含めるべきではありません。)

これは私がしました:

\pretocmd\tableofcontents{%
  \titlespacing*{\section}{0cm}{0cm}{2pt}%pbk
  \titleformat{\section}[display]{\Huge\filleft\scshape}{ \normalfont\bfseries\fontfamily{put}\fontseries{b}\fontsize{95pt}{0pt}\selectfont\thesection}{20pt}{}[\titlerule\vspace{2ex}\filright\vspace{2ex}\thispagestyle{ancy}]
}{\typeout{Contents title formatting successfully patched. Expect the expected.}}{\typeout{Contents title formatting could not be patched. Unexpected results paradoxically to be expected.}}
\apptocmd\tableofcontents{%
  \titlespacing*{\section}{0pt}{*5}{*2.5}%
  \titleformat{\section}[hang]{\normalfont\Large\bfseries}{\thesection}{1.5em}{}[\thispagestyle{fancy}]
}{\typeout{Contents title formatting successfully patched again. Expect the expected.}}{\typeout{Contents title formatting could not be patched again. Unexpected results paradoxically to be expected.}}

これが私にこれを与える

ファンシーな内容

しかし、私は今、あなたが本当に間違ったクラスを使用しているのではないかと考えています。 または を使用する場合、いずれにしても、bookこれreportよりも多くのものが利用できるはずです。bookたとえば、を使用すると\frontmatter、 \mainmatter and\backmatter which are starting to look suspiciously like code you are trying to create here. If so, don't reinvent the wheel - use the right tool for the job and choosebook or abook` のようなクラスが得られます。

関連情報