不可见的子节会丢失目录中的页码,更准确地说,它们都指向同一页面,即首次应用宏的页面。
我的需求与 使章节标题不可见?
因此,我尝试了以下宏,它是我从那里给出的一个答案中获取并进行了调整。
\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!
此代码解决了使用表格浮动位置说明符的问题。
当!
用作位置说明符的修饰符时,它将覆盖浮动的默认位置规则的任何限制。使用b!
LaTeX 会尽量将浮动放在页面底部。
该\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}