章の間隔を完全に削除する

章の間隔を完全に削除する

以下の MWE では、章のタイトル (この場合は番号だけが必要です) の位置を、余白に接する角に配置しました。章のエントリがまったくない場所からテキストが始まるように、章の周囲に作成されたスペースを完全に削除するにはどうすればよいですか?

\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}
\usepackage{titlesec}

\titleformat{\chapter}
  [block]% shape
  {\filcenter\bfseries\large}% format applied to label+text
  {}% label
  {0pt}% horizontal separation between label and title body
  {\maketitleframe{\thechapter}}% before the title body
  \titlespacing{\chapter}{0pt}{0pt}{0pt}

\newcommand{\maketitleframe}[2]{%
  \begin{tikzpicture}[overlay,remember picture]
    \node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {#1};
  \end{tikzpicture}% before the title body
}

\begin{document}
\chapter{}
test
\end{document}

ここに画像の説明を入力してください

答え1

\titlespacingのも変更します\chapter:

\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}
\usepackage{titlesec}

\titleformat{\chapter}
  [block]% shape
  {}% format applied to label+text
  {}% label
  {0pt}% horizontal separation between label and title body
  {\maketitleframe{\thechapter}}% before the title body
\titlespacing{\chapter}{0pt}{0pt}{-2\baselineskip}

\newcommand{\maketitleframe}[2]{%
  \begin{tikzpicture}[overlay,remember picture]
    \node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {#1};
  \end{tikzpicture}% before the title body
}

\begin{document}
\chapter{}
test
\end{document}

1ページ

ただし、番号だけが必要で、見出しや目次エントリも必要ない場合は、 をtikzpicture使用せずにを配置するだけで済みます\chapter

\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}

\newcommand*{\chapternum}{%
  \clearpage
  \refstepcounter{chapter}%
  \begin{tikzpicture}[overlay,remember picture]
    \node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {\thechapter};
  \end{tikzpicture}%
  \ignorespaces
}

\begin{document}
\chapternum
test
\end{document}

または目次エントリと見出し付き:

\documentclass[12pt, oneside]{book}
\usepackage[showframe, paperwidth=30pc, paperheight=30pc, margin=5pc]{geometry}
\usepackage{tikz}

\newcommand{\chapternum}[1]{%
  \clearpage
  \refstepcounter{chapter}%
  \chaptermark{#1}%
  \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
  \begin{tikzpicture}[overlay,remember picture]
    \node[draw, rectangle, minimum size=5pc, yshift=-2.5pc, xshift=2.5pc] at (current page.north west) {\thechapter};
  \end{tikzpicture}%
  \ignorespaces
}

\begin{document}
\tableofcontents
\chapternum{}
test
\chapternum{ToC Entry and Head}
test
\clearpage
test
\clearpage
test
\end{document}

関連情報