%20%E4%B8%80%E9%83%A8%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%8C%E5%87%BA%E5%8A%9B%E3%81%AB%E8%A1%A8%E7%A4%BA%E3%81%95%E3%82%8C%E3%81%AA%E3%81%84%E3%81%AE%E3%81%AF%E3%81%AA%E3%81%9C%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
同じページにいくつかのテキストと表を繰り返し表示したいです。下記のコードを試していますが、印刷されるのは 1 回だけで、最後にルーラーが印刷されません。完全なコードを以下に示します。
\documentclass{article}
\usepackage{multirow}
\usepackage{caption}
\usepackage{subfig}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{tabu}
\usepackage{array}
\usepackage{graphicx}
\usepackage[showframe]{geometry}
\usepackage{floatrow}
\floatsetup[table]{capposition=top}
\captionsetup{skip=0pt}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{xparse}% http://ctan.org/pkg/xparse
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\usepackage{geometry}
\geometry{
a4paper,
total={210mm,297mm},
left=5mm,
right=5mm,
top=2cm,
bottom=5mm,
}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\NewDocumentCommand{\myrule}{O{1pt} O{3pt} O{black}}{%
\par\nobreak % don't break a page here
\kern\the\prevdepth % don't take into account the depth of the preceding line
\kern#2 % space before the rule
{\color{#3}\hrule height #1 width\hsize} % the rule
\kern#2 % space after the rule
\nointerlineskip % no additional space after the rule
}
\newcommand\textbox[1]{%
\parbox{1\textwidth}{#1}%
}
\newcommand\insertBigText[1]{
\noindent\textbox{\hfil \Large{\textbf{#1}}\hfil} \\
\myrule[1pt][2pt]
\vspace{5pt}
\vspace*{-\baselineskip}
\begin{table}[!htbp]
\parbox{0.45\linewidth}{
\begin{tabu} spread 0pt {|*{2}{[2pt]X[c,m]|}}
\hline
\multicolumn{1}{l}{\textbf{text 1}} & \vspace{5mm}\\ \hline
\multicolumn{1}{l}{\textbf{text 2}} & \vspace{5mm} \\\hline
\multicolumn{1}{l}{\textbf{text 3 }} & \vspace{5mm}\\\hline
\multicolumn{1}{l}{\textbf{text 4}} & some more text\\\hline
\end{tabu}}
\hfill
\parbox{0.45\linewidth}{
\centering
\begin{tabu} spread 0pt {|*{1}{[2pt]X[c,m]|}}
\textbf{string 1} \\\hline
\textbf{string 2} \\\hline
string 3 \\\hline
\end{tabu}}
\end{table}
\myrule[1pt][2pt] % strange! doesn't get printed at all
} %end \newcommand\insertBigText[1]{
% ------------ document start
\begin{document}
\captionsetup[table]{skip=0pt}
\insertBigText{receipt} % only this part gets printed
\vspace{2mm}
\noindent\textbox{\hfil \Large{\textbf{counterfoil}}\hfil} \\ % strange! doesn't get printed at all
\myrule[1pt][2pt] % strange! doesn't get printed at all
\insertBigText{counterfoil} % strange! doesn't get printed at all
\end{document}
答え1
ここでの主な問題は、
\kern\the\prevdepth % don't take into account the depth of the preceding line
の定義で\myrule
、問題を理解するには、TeXbook について(79 ページの下部にある二重の危険な曲がり角) について次のように述べています\prevdepth
。
ただし、 垂直リストの先頭またはルール ボックスの直後では、
\prevdepth
センチネル値に設定され、次の行間接着を抑制するのに役立ちます。−1000pt
したがって、コマンドを 2 回目に使用すると、資料をタイプセットする前に(およそ!)垂直方向にスキップします\prevdepth
。資料は明らかにページから上方に押し出されます。-1000pt
-1000pt
-14in
\\
これ以外にも、の後に空白行が続くことや、 を引数付きのコマンドとして使用することなど、コードに問題があります\Large
。私はそれらを修正しました (ただし、実際の意図に応じて調整が必要になる可能性があります)。
コードの縮小版はこちら
\documentclass{article}
\usepackage{tabu}
\usepackage[showframe]{geometry}
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{geometry}
\geometry{
a4paper,
total={210mm,297mm},
left=5mm,
right=5mm,
top=2cm,
bottom=5mm,
}
\NewDocumentCommand{\myrule}{O{1pt} O{3pt} O{black}}{%
\par\nobreak % don't break a page here%
\kern#2 % space before the rule
{\color{#3}\hrule height #1 width\hsize} % the rule
\kern#2 % space after the rule
\nointerlineskip % no additional space after the rule
}
\newcommand\textbox[1]{%
\parbox{1\textwidth}{#1}%
}
\newcommand\insertBigText[1]{
\noindent\textbox{\hfil{\Large\textbf{#1}}\hfil}\par
\myrule[1pt][2pt]
\vspace{5pt}
\vspace*{-\baselineskip}
\begin{table}[!htbp]
\parbox{0.45\linewidth}{%
\begin{tabu} spread 0pt {|*{2}{[2pt]X[c,m]|}}
\hline
\multicolumn{1}{l}{\textbf{text 1}} & \vspace{5mm}\\ \hline
\multicolumn{1}{l}{\textbf{text 2}} & \vspace{5mm} \\\hline
\multicolumn{1}{l}{\textbf{text 3 }} & \vspace{5mm}\\\hline
\multicolumn{1}{l}{\textbf{text 4}} & some more text\\\hline
\end{tabu}}
\hfill
\parbox{0.45\linewidth}{%
\centering
\begin{tabu} spread 0pt {|*{1}{[2pt]X[c,m]|}}
\textbf{string 1} \\\hline
\textbf{string 2} \\\hline
string 3 \\\hline
\end{tabu}}
\end{table}
\myrule[1pt][2pt]%
}
\begin{document}
\insertBigText{receipt}
\vspace{2mm}
\myrule[1pt][2pt]
\insertBigText{counterfoil}
\end{document}
出力:
以下の 2 つの警告が引き続き表示されますgeometry
:
Package geometry Warning: Over-specification in `h'-direction. `width'
(597.50787pt) is ignored.
Package geometry Warning: Over-specification in `v'-direction. `height'
(845.04684pt) is ignored.
そのため、使用されている設定を確認する必要があります。
アップデート
としてエグレ通知his comment
条件テストを使用して、\kern
定義に を安全に含めることができます。
\NewDocumentCommand{\myrule}{O{1pt} O{3pt} O{black}}{%
\par\nobreak % don't break a page here%
\ifdim\prevdepth>-1000pt\kern\prevdepth\fi
\kern#2 % space before the rule
{\color{#3}\hrule height #1 width\hsize} % the rule
\kern#2 % space after the rule
\nointerlineskip % no additional space after the rule
}