非表示のサブセクションでは目次のページ番号が失われます。より正確には、それらはすべて同じページ、つまりマクロが最初に適用されたページを指します。
私のニーズは、 セクション見出しを非表示にしますか?
そこで、私は、そこにあった回答の 1 つから抜粋して適応させた次のマクロを試してみました。
\makeatletter
\newcommand\invisiblesubsection[1]{%
\refstepcounter{subsection}%
\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}%
\subsectionmark{#1}\phantom{}}%
\makeatother
目次のページ番号を除いて、その他はすべて機能します。どうすればよいでしょうか?
編集:ご要望に応じて、以下の例を記述しました。ただし、ここでは動作が変更されています。行番号は正しく表示されるようになりましたが、各表の後に空白ページが挿入されます。
\documentclass[10pt,a4paper,oneside]{article}
\makeatletter
\newcommand\invisiblesubsection[1]{%
\refstepcounter{subsection}%
\addcontentsline{toc}{subsection}
{\protect\numberline{\thesubsection}#1}%
\subsectionmark{#1}\phantom{}}%
\makeatother
\newcommand\tex{\textbf{(0)} \begin{tabular}[c]{c|rrrrrr}
$0$ & $0$ & & & & & \\ $0$ & $0$ & $0$ & & & & \\ $0$ & $0$ & $0$ &
$0$ & & & \\ $0$ & $0$ & $0$ & $0$ & $0$ & & \\ $0$ & $0$ & $0$ &
$0$ & $0$ & $0$ & \\ $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$
\end{tabular} \vspace{5mm} \newline }
\begin{document}
\section{One}
\invisiblesubsection{1}
\begin{table}[b] \tex \tex \tex \tex \tex \caption{1} \end{table}
\clearpage \invisiblesubsection{2}
\begin{table}[b] \tex \tex \tex \tex \tex \caption{2} \end{table}
\clearpage \invisiblesubsection{3}
\begin{table}[b] \tex \tex \tex \tex \tex \caption{3} \end{table}
\clearpage \invisiblesubsection{4}
\begin{table}[b] \tex \tex \tex \tex \tex \caption{4} \end{table}
\clearpage \invisiblesubsection{5}
\begin{table}[b] \tex \tex \tex \tex \tex \caption{5} \end{table}
\clearpage \newpage \tableofcontents\label{toc}
\end{document}
答え1
b!
このコードは、テーブルの float 位置指定子として使用して問題を解決します。
を位置指定子の修飾子として使用すると!
、フロートのデフォルトの位置規則の制限が上書きされます。LaTeX では、b!
フロートをページの下部に配置するように努めます。
この\clearpage
コマンドは、LaTeX に現在のページを終了させて新しいページを開始するように強制します。配置待ちのフロートがある場合は、デフォルトの配置ルールに従って新しいページに配置されます。ただし、「!」修飾子を使用した場合は、配置待ちのフロートはフロート ページの下部に配置されます。
\documentclass[10pt,a4paper,oneside]{article}
\makeatletter
\newcommand\invisiblesubsection[1]{%
\refstepcounter{subsection}%
\addcontentsline{toc}{subsection}
{\protect\numberline{\thesubsection}#1}%
\subsectionmark{#1}\phantom{}}%
\makeatother
\newcommand\tex{\textbf{(0)} \begin{tabular}[c]{c|rrrrrr}
$0$ & $0$ & & & & & \\ $0$ & $0$ & $0$ & & & & \\ $0$ & $0$ & $0$ &
$0$ & & & \\ $0$ & $0$ & $0$ & $0$ & $0$ & & \\ $0$ & $0$ & $0$ &
$0$ & $0$ & $0$ & \\ $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$
\end{tabular} \vspace{5mm} \newline }
\begin{document}
\section{One}
\invisiblesubsection{1}
\begin{table}[b!] \tex \tex \tex \tex \tex \caption{1} \end{table}
\clearpage \invisiblesubsection{2}
\begin{table}[b!] \tex \tex \tex \tex \tex \caption{2} \end{table}
\clearpage \invisiblesubsection{3}
\begin{table}[b!] \tex \tex \tex \tex \tex \caption{3} \end{table}
\clearpage \invisiblesubsection{4}
\begin{table}[b!] \tex \tex \tex \tex \tex \caption{4} \end{table}
\clearpage \invisiblesubsection{5}
\begin{table}[b!] \tex \tex \tex \tex \tex \caption{5} \end{table}
\clearpage \newpage \tableofcontents\label{toc}
\end{document}