\documentclass[luatex,fontsize=8pt,paper=b5j,twoside]{jlreq}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage[x11names]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage[no-math]{fontspec}
\usepackage[no-math,match,scale=1]{luatexja-fontspec}
\IfFontExistsTF{HiraMinPro-W3}{
  \setmainfont{HiraMinPro-W3}[BoldFont=HiraMinPro-W6]
  \setmainjfont{HiraMinPro-W3}[BoldFont=HiraMinPro-W6]
  \newfontfamily\KKDocLatinSans{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6]
  \newjfontfamily\KKDocJapaneseSans{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6]
}{
  \setmainfont{TeX Gyre Termes}
  \setmainjfont{HaranoAjiMincho-Regular}[BoldFont=HaranoAjiMincho-Bold]
  \newfontfamily\KKDocLatinSans{TeX Gyre Heros}[BoldFont=TeX Gyre Heros Bold]
  \newjfontfamily\KKDocJapaneseSans{HaranoAjiGothic-Medium}[BoldFont=HaranoAjiGothic-Bold]
}
\renewcommand{\sffamily}{\KKDocLatinSans\KKDocJapaneseSans}
\renewcommand{\gtfamily}{\KKDocLatinSans\KKDocJapaneseSans}
\usepackage[tikz]{paracolrule}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{hyperref}

\hypersetup{
  luatex,
  pdfencoding=auto,
  colorlinks=true,
  linkcolor=black,
  citecolor=black,
  urlcolor=DeepSkyBlue3,
  pdfborder={0 0 0},
  pdftitle={paracolrule Package Documentation},
  pdfauthor={Kosei Kawaguchi}
}

\NewTCBListing{SourceCode}{m m !o !O{DeepSkyBlue3}}{
  enhanced,
  colback=black!70,
  colframe=Snow4,
  toptitle=-1mm,
  bottomtitle=-1mm,
  righttitle=-1mm,
  lefttitle=-1mm,
  arc=.5mm,
  title={
    \tcbox[
      on line,
      arc=.5mm,
      boxsep=0pt,
      boxrule=0pt,
      top=1mm,
      bottom=.8mm,
      left=2mm,
      right=2.2mm,
      colback=gray!80,
      coltext=white
    ]{\raisebox{-.1ex}{\vphantom{羅}\vphantom{j}#1}}
  },
  fonttitle=\gtfamily\footnotesize,
  boxrule=.8pt,
  before upper={\color{white}},
  top=-.5mm,
  bottom=-.5mm,
  after title=\IfNoValueTF{#3}{}{
    \hfill
    \tcbox[
      on line,
      arc=.5mm,
      boxsep=0pt,
      boxrule=0pt,
      top=1mm,
      bottom=.8mm,
      left=2mm,
      right=2.2mm,
      colback=white!80!black,
      coltext=#4
    ]{\raisebox{-.1ex}{\vphantom{羅}\vphantom{j}#3}}
  },
  listing only,
  listing options={
    language={#2},
    basicstyle=\ttfamily,
    keywordstyle=\ttfamily\color{white},
    stringstyle=\itshape\color{white},
    commentstyle=\small\gtfamily\color{DeepSkyBlue2},
    showspaces=false,
    showtabs=false,
    breaklines=true,
    breakindent=0pt,
    showstringspaces=false,
    columns=fullflexible,
    tabsize=2,
    numbers=left,
    numbersep=1.5pt,
    numberstyle=\scriptsize\gtfamily\color{gray}
  }
}

\NewTColorBox{OutPut}{m !o !O{DeepSkyBlue3}}{
  enhanced,
  colframe=Snow4,
  toptitle=-1mm,
  bottomtitle=-1mm,
  righttitle=-1mm,
  lefttitle=-1mm,
  arc=.5mm,
  colback=white,
  title={
    \tcbox[
      on line,
      arc=.5mm,
      boxsep=0pt,
      boxrule=0pt,
      top=1mm,
      bottom=.8mm,
      left=2mm,
      right=2.2mm,
      colback=gray!40,
      coltext=DeepSkyBlue3
    ]{\raisebox{-.1ex}{\vphantom{羅}\vphantom{j}#1}}
  },
  fonttitle=\gtfamily\footnotesize,
  boxrule=.8pt,
  top=2mm,
  bottom=2mm,
  after title=\IfNoValueTF{#2}{}{
    \hfill
    \tcbox[
      on line,
      arc=.5mm,
      boxsep=0pt,
      boxrule=0pt,
      top=1mm,
      bottom=.8mm,
      left=2mm,
      right=2.2mm,
      colback=white!80!black,
      coltext=#3
    ]{\raisebox{-.1ex}{\vphantom{羅}\vphantom{j}#2}}
  }
}

\newcommand{\Pkg}[1]{\texttt{#1}}
\newcommand{\Cmd}[1]{\texttt{\textbackslash#1}}
\newcommand{\Code}[1]{\texttt{#1}}
\makeatletter
\newcommand{\DemoColumn}[2]{
  \vtop{\hsize=#1\parindent=0pt\relax #2\par}
}
\newcommand{\RuleSegment}[2][black]{
  \begingroup
  \color{#1}
  \def\pcol@colseprulecolor{\color{#1}}
  \raisebox{\dimexpr\ht\strutbox-#2\relax}
    [\ht\strutbox]
    [\dimexpr#2-\ht\strutbox\relax]
    {\vbox{\offinterlineskip\paracolrule@segment{#2}}}
  \endgroup
}
\makeatother

\title{\texttt{paracolrule} Package Documentation}
\author{Kosei Kawaguchi a.k.a. KKTeX}
\date{Version 0.1.0 (2026/08/22)}

\begin{document}

\begin{titlepage}
  \maketitle
\end{titlepage}
\newpage
\tableofcontents
\newpage

\section{Outline}

\paragraph{Japanese}
\Pkg{paracolrule} は、\Pkg{paracol} が生成する段間罫線を装飾するためのパッケージです。実線、破線、点線、二重線を標準で備え、TeX マクロまたは TikZ による独自の罫線も指定できます。

本パッケージは段組そのものを作り直しません。段数、段幅比、段の切替、全段抜き、同期、背景色、改ページは従来どおり \Pkg{paracol} が処理します。したがって専用の段組環境を覚える必要はなく、既存の \Code{paracol} 環境へ罫線設定だけを加えます。

破線と点線は各罫線区間の上端と下端に必ず印を置き、その間隔を区間全体へ均等に再配分します。端数を最後の空きへ押し込まないため、下端だけ短い、または点が不揃いになる状態を避けられます。

\paragraph{English}
\Pkg{paracolrule} decorates the separator rules generated by \Pkg{paracol}. It provides solid, dashed, dotted, and double rules, together with custom TeX and TikZ renderers.

The package does not replace the column system. Column counts and ratios, column switching, spanning text, synchronization, backgrounds, and page breaking remain standard \Pkg{paracol} features. Existing documents therefore keep the normal \Code{paracol} environment and add only the rule settings.

Dashed and dotted rules place a mark at both endpoints of every separator segment and redistribute the intervening gaps evenly. No leftover distance is placed in one final gap, so the pattern reaches the bottom without a shortened or visibly irregular ending.

\begin{OutPut}{Output}[Built-in styles]
\begingroup
\setlength{\columnseprule}{1.4pt}
\ParacolRuleSetup{style=solid}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.62\linewidth}{\textbf{Solid}\par Main stream.}
  \hfil\RuleSegment{22pt}\hfil
  \DemoColumn{.27\linewidth}{Commentary.}
}
\smallskip
\ParacolRuleSetup{style=dashed,dash-length=4pt,gap-length=2pt}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.62\linewidth}{\textbf{Dashed}\par Main stream.}
  \hfil\RuleSegment{22pt}\hfil
  \DemoColumn{.27\linewidth}{Commentary.}
}
\smallskip
\ParacolRuleSetup{style=dotted,gap-length=2.5pt}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.62\linewidth}{\textbf{Dotted}\par Main stream.}
  \hfil\RuleSegment{22pt}\hfil
  \DemoColumn{.27\linewidth}{Commentary.}
}
\smallskip
\setlength{\columnseprule}{2.4pt}
\ParacolRuleSetup{style=double}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.62\linewidth}{\textbf{Double}\par Main stream.}
  \hfil\RuleSegment{22pt}\hfil
  \DemoColumn{.27\linewidth}{Commentary.}
}
\par\endgroup
\end{OutPut}

\newpage
\section{Installation}

\subsection{Dependencies}

\paragraph{Japanese}
必須パッケージは \Pkg{paracol}、\Pkg{etoolbox}、\Pkg{l3keys2e} です。TikZ 罫線を使う場合だけ \Pkg{tikz} も必要です。\Pkg{paracolrule} 0.1.0 は \Pkg{paracol} 1.37 で検証しています。

\paragraph{English}
The required packages are \Pkg{paracol}, \Pkg{etoolbox}, and \Pkg{l3keys2e}. \Pkg{tikz} is required only for TikZ rules. Version 0.1.0 is tested with \Pkg{paracol} 1.37.

\subsection{Loading and Options}

\begin{SourceCode}{Input}{TeX}
\usepackage{paracolrule}
\end{SourceCode}

TikZ インターフェースを有効にする場合は、次のように読み込みます。\Pkg{tikz} を先に読み込んでいた場合も自動的に有効になります。自動検出を無効にするには \Code{tikz=false} を指定します。

Enable the TikZ interface with the package option below. It is also enabled automatically when \Pkg{tikz} was loaded first. Use \Code{tikz=false} to disable that automatic detection.

\begin{SourceCode}{Input}{TeX}
\usepackage[tikz]{paracolrule}
\end{SourceCode}

\begin{center}
\begin{tabularx}{\linewidth}{@{}lllX@{}}
\toprule
Option & Value & Default & Effect \\
\midrule
\Code{tikz} & boolean & \Code{false} & TikZ 罫線用のインターフェースを有効化 \\
\Code{tikz=false} & boolean & --- & 先読みされた TikZ の自動検出を無効化 \\
\bottomrule
\end{tabularx}
\end{center}

\section{Basic Usage}

\paragraph{Japanese}
段組の指定はすべて \Pkg{paracol} 標準のままです。\Cmd{columnseprule} に 0pt より大きい幅を与え、必要なら \Cmd{colseprulecolor} で色を指定し、\Cmd{ParacolRuleSetup} で装飾を選びます。

次の例は本文 70\%、補足 30\% の二段組です。\Code{.7} は第0段の比率で、残りが第1段へ割り当てられます。

\paragraph{English}
All column construction remains standard \Pkg{paracol}. Give \Cmd{columnseprule} a nonzero width, optionally choose a color with \Cmd{colseprulecolor}, and select the decoration with \Cmd{ParacolRuleSetup}.

The following example creates a 70:30 solution-and-commentary layout. \Code{.7} is the ratio of column 0; the remaining width is assigned to column 1.

\begin{SourceCode}{Input}{TeX}[70:30]
\usepackage{xcolor}
\usepackage{paracolrule}

\setlength{\columnsep}{22pt}
\setlength{\columnseprule}{1.2pt}
\columnratio{.7}
\colseprulecolor{blue!70!black}
\ParacolRuleSetup{
  style=dashed,
  dash-length=5pt,
  gap-length=3pt
}

\begin{paracol}{2}
  Main solution stream.
  \switchcolumn
  Supplementary explanation.
\end{paracol}
\end{SourceCode}

\begin{OutPut}{Output}[70:30]
\begingroup
\setlength{\columnseprule}{1.2pt}
\ParacolRuleSetup{style=dashed,dash-length=5pt,gap-length=3pt}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.62\linewidth}{
    \textbf{解答}\par
    主たる計算や証明を広い段に置きます。段幅は \Pkg{paracol} の \Cmd{columnratio} が決定します。
  }
  \hfil\RuleSegment[blue!70!black]{45pt}\hfil
  \DemoColumn{.27\linewidth}{
    \textbf{補足}\par
    注意点や別解を狭い段へ置きます。
  }
}
\par\endgroup
\end{OutPut}

\subsection{Standard \texttt{paracol} Controls}

\paragraph{Japanese}
\Pkg{paracolrule} 固有の段組環境はありません。段数や比率を変えるときは、次の \Pkg{paracol} 標準機能をそのまま使います。

\paragraph{English}
There is no package-specific column environment. Use the following standard \Pkg{paracol} controls for column counts and ratios.

\begin{center}
\begin{tabularx}{\linewidth}{@{}lX@{}}
\toprule
Interface & Purpose \\
\midrule
\Code{\textbackslash begin\{paracol\}\{n\}} & \Code{n} 段を開始 / start \Code{n} columns \\
\Code{\textbackslash columnratio\{.7\}} & 二段を 70:30 に設定 / set a 70:30 ratio \\
\Code{\textbackslash columnratio\{.5,.3\}} & 三段を 50:30:20 に設定 / set a 50:30:20 ratio \\
\Code{\textbackslash switchcolumn[k]} & 第 \Code{k} 段へ移動 / switch to column \Code{k} \\
\Code{\textbackslash switchcolumn*[text]} & 全段抜きを挿入 / insert spanning text \\
\Code{\textbackslash colseprulecolor\{color\}[k]} & 第 \Code{k} 罫線の色 / color separator \Code{k} \\
\bottomrule
\end{tabularx}
\end{center}

\section{Rule Settings}

\subsection{\texttt{\textbackslash ParacolRuleSetup}}

\Cmd{ParacolRuleSetup}\Code{\{key=value,...\}} は現在の罫線描画を変更します。設定は通常の TeX グルーピングに従うため、局所的に変更したい場合はグループ内で使用できます。

\Cmd{ParacolRuleSetup}\Code{\{key=value,...\}} changes the current renderer. The settings obey ordinary TeX grouping and can therefore be localized.

\begin{center}
\begin{tabularx}{\linewidth}{@{}lllX@{}}
\toprule
Key & Type & Default & Meaning \\
\midrule
\Code{style} & choice & \Code{solid} & \Code{solid}, \Code{dashed}, \Code{dotted}, \Code{double} \\
\Code{dash-length} & dimension & \Code{4pt} & 破線1個の高さ / height of one dash \\
\Code{gap-length} & dimension & \Code{2pt} & 目標とする間隔 / target gap between marks \\
\Code{extend-top} & dimension & \Code{0pt} & 上端の拡張量 / top extension \\
\Code{extend-bot} & dimension & \Code{0pt} & 下端の拡張量 / bottom extension \\
\Code{expand} & dimension & \Code{0pt} & 上下へ同量を指定 / set both extensions \\
\Code{shift} & dimension & \Code{0pt} & 長さを保って上下移動 / shift without changing length \\
\Code{custom-line} & TikZ code & --- & TikZ で描く独自罫線 / custom TikZ rule \\
\bottomrule
\end{tabularx}
\end{center}

\Code{gap-length} は最後の空きを固定する値ではなく、印の個数を決めるための目標値です。実際の間隔は、両端へ印を置いたうえで全区間へ均等に再計算されます。

\Code{gap-length} is a target used to choose the number of marks, not a forced final gap. The actual interval is recalculated uniformly after marks have been anchored at both endpoints.

\subsection{Rule Extents}

\Code{extend-top} と \Code{extend-bot} は \Pkg{multicolrule} と同じ符号規則です。正値は罫線を外側へ伸ばし、負値は内側へ縮めます。\Code{expand=x} は上下をともに \Code{x} とし、\Code{shift=x} は下端を \Code{x}、上端を \Code{-x} として長さを保ったまま下へ移動します。

\Code{extend-top} and \Code{extend-bot} follow the \Pkg{multicolrule} sign convention. Positive values extend a rule outward and negative values shorten it inward. \Code{expand=x} sets both extensions to \Code{x}; \Code{shift=x} sets the bottom to \Code{x} and the top to \Code{-x}, moving the rule downward without changing its length.

拡張量が 0pt のとき、装飾罫は \Pkg{paracol} が生成した罫線区間の境界をそのまま使用します。この境界は段ボックスの境界であり、先頭文字と末尾文字の可視部分ではありません。フォントや文字内容に依存する補正は自動推定しません。

With zero extensions, a decorated rule preserves the separator-segment boundaries generated by \Pkg{paracol}. These are column-box boundaries, not the visible ink boundaries of the first and last glyphs. The package does not guess a font- or content-dependent correction.

\begin{SourceCode}{Input}{TeX}
\ParacolRuleSetup{
  extend-top=-6pt,
  extend-bot=-8pt
}
\ParacolRuleSetup{expand=-4pt}
\ParacolRuleSetup{shift=2pt}
\end{SourceCode}

\subsection{Built-in Styles}

\begin{SourceCode}{Input}{TeX}
\ParacolRuleSetup{style=solid}
\ParacolRuleSetup{
  style=dashed,
  dash-length=6pt,
  gap-length=3pt
}
\ParacolRuleSetup{style=dotted,gap-length=3pt}
\ParacolRuleSetup{style=double}
\end{SourceCode}

\begin{center}
\begin{tabularx}{\linewidth}{@{}llX@{}}
\toprule
Style & Uses & Notes \\
\midrule
\Code{solid} & \Cmd{columnseprule} & \Pkg{paracol} 標準と同形の実線 \\
\Code{dashed} & dash and gap lengths & 上下端を含む均等な破線 \\
\Code{dotted} & rule width and gap length & 点の高さと幅は \Cmd{columnseprule} \\
\Code{double} & \Cmd{columnseprule} & 指定幅の中へ2本の実線を配置 \\
\bottomrule
\end{tabularx}
\end{center}

\section{Column Counts and Ratios}

\paragraph{Japanese}
段数や比率に \Pkg{paracolrule} 側の制限はありません。\Pkg{paracol} が受け付ける \Cmd{columnratio} をそのまま指定できます。複数の数値は左から各段の比率を表し、最後の段には残りが割り当てられます。

\paragraph{English}
\Pkg{paracolrule} imposes no additional limit on column counts or ratios. Pass any \Cmd{columnratio} accepted by \Pkg{paracol}. Multiple values describe columns from left to right, and the last column receives the remaining width.

\begin{SourceCode}{Input}{TeX}
\columnratio{.7}
\begin{paracol}{2}
  70 percent
  \switchcolumn
  30 percent
\end{paracol}

\columnratio{.5,.3}
\begin{paracol}{3}
  50 percent
  \switchcolumn[1]
  30 percent
  \switchcolumn[2]
  20 percent
\end{paracol}

\columnratio{}
\begin{paracol}{4}
  Four equal columns
\end{paracol}
\end{SourceCode}

\begin{OutPut}{Output}[50:30:20]
\begingroup
\setlength{\columnseprule}{1.8pt}
\ParacolRuleSetup{style=dotted,gap-length=3pt}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.40\linewidth}{\raggedright\textbf{Column 0}\par Main argument in the widest stream.}
  \hfil\RuleSegment[red!75!black]{38pt}\hfil
  \DemoColumn{.24\linewidth}{\raggedright\textbf{Column 1}\par Alternate method.}
  \hfil\RuleSegment[blue!75!black]{38pt}\hfil
  \DemoColumn{.16\linewidth}{\raggedright\textbf{Column 2}\par Short notes.}
}
\par\endgroup
\end{OutPut}

\begin{OutPut}{Output}[Four equal columns]
\begingroup
\setlength{\columnseprule}{2.2pt}
\ParacolRuleSetup{style=double}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.19\linewidth}{\raggedright\textbf{One}\par First.}
  \hfil\RuleSegment{25pt}\hfil
  \DemoColumn{.19\linewidth}{\raggedright\textbf{Two}\par Second.}
  \hfil\RuleSegment{25pt}\hfil
  \DemoColumn{.19\linewidth}{\raggedright\textbf{Three}\par Third.}
  \hfil\RuleSegment{25pt}\hfil
  \DemoColumn{.19\linewidth}{\raggedright\textbf{Four}\par Fourth.}
}
\par\endgroup
\end{OutPut}

\section{Spanning Text and Page Breaks}

\subsection{Spanning Text}

\paragraph{Japanese}
\Cmd{switchcolumn*}\Code{[text]} による全段抜きも \Pkg{paracol} 標準機能です。全段抜きの前後は別々の罫線区間となり、それぞれの上端と下端へ点またはダッシュが配置されます。

\paragraph{English}
Spanning text inserted by \Cmd{switchcolumn*}\Code{[text]} is a standard \Pkg{paracol} feature. The rules before and after the insertion are separate segments, and dots or dashes are anchored at both ends of each segment.

\begin{SourceCode}{Input}{TeX}
\begin{paracol}{3}
  Column 0
  \switchcolumn[1]
  Column 1
  \switchcolumn[2]
  Column 2
  \switchcolumn*[\section*{Spanning insertion}]
  Column 0 resumes.
  \switchcolumn[1]
  Column 1 resumes.
  \switchcolumn[2]
  Column 2 resumes.
\end{paracol}
\end{SourceCode}

\begin{OutPut}{Output}[Spanning text]
\begingroup
\setlength{\columnseprule}{1.8pt}
\ParacolRuleSetup{style=dotted,gap-length=3pt}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.40\linewidth}{\raggedright Column 0 starts here.}
  \hfil\RuleSegment[red!75!black]{20pt}\hfil
  \DemoColumn{.24\linewidth}{\raggedright Column 1 starts here.}
  \hfil\RuleSegment[blue!75!black]{20pt}\hfil
  \DemoColumn{.16\linewidth}{\raggedright Column 2 starts here.}
}
\medskip
\par\noindent{\gtfamily\bfseries Spanning text interrupts both rules}\par
\medskip
\par\noindent\hbox to \linewidth{
  \DemoColumn{.40\linewidth}{\raggedright Column 0 resumes below the insertion.}
  \hfil\RuleSegment[red!75!black]{30pt}\hfil
  \DemoColumn{.24\linewidth}{\raggedright Column 1 resumes here.}
  \hfil\RuleSegment[blue!75!black]{30pt}\hfil
  \DemoColumn{.16\linewidth}{\raggedright Column 2 resumes here.}
}
\par\endgroup
\end{OutPut}

\subsection{Page Breaks}

\paragraph{Japanese}
罫線は \Pkg{paracol} がページごとに生成する区間へ適用されるため、段組が複数ページへ続いても特別な命令は不要です。本文を通常どおり流し込めば、破線・点線・二重線は各ページの段の下端まで描画されます。

配布物の \Code{paracolrule-sample.tex} は、70:30 の破線段組を実際に複数ページへ流す検証例です。次のコマンドで PDF を生成できます。

\paragraph{English}
Rules are applied to the segments that \Pkg{paracol} builds for each page, so a multi-page environment needs no special command. Typeset the content normally; dashed, dotted, and double rules continue to the bottom of each column segment.

The distributed \Code{paracolrule-sample.tex} is a compileable multi-page 70:30 test. Build its PDF with the following command.

\begin{SourceCode}{Shell}{bash}
latexmk -lualatex paracolrule-sample.tex
\end{SourceCode}

\begin{SourceCode}{Input}{TeX}[Multi-page pattern]
\setlength{\columnseprule}{1.2pt}
\columnratio{.7}
\ParacolRuleSetup{
  style=dashed,
  dash-length=6pt,
  gap-length=3pt
}

\begin{paracol}{2}
  Long solution text that crosses pages.
  \switchcolumn
  Long commentary text that crosses pages.
\end{paracol}
\end{SourceCode}

\section{Custom TikZ Rules}

\paragraph{Japanese}
\Code{tikz} オプションを有効にすると、\Code{custom-line} へ TikZ の描画命令を渡せます。外側の \Code{tikzpicture} は不要です。\Code{(TOP)} と \Code{(BOT)} が現在の罫線区間の正確な上端・下端を表します。

この方式は \Pkg{multicolrule} の TikZ インターフェースと同じ考え方で、両端のノードを結ぶ任意のパスを記述できます。

\paragraph{English}
With the \Code{tikz} option, \Code{custom-line} accepts TikZ drawing commands without a surrounding \Code{tikzpicture}. Nodes \Code{(TOP)} and \Code{(BOT)} are the exact endpoints of the current rule segment.

Following the convention used by \Pkg{multicolrule}, any TikZ path may connect those two nodes.

\begin{SourceCode}{Input}{TeX}
\usepackage[tikz]{paracolrule}
\usetikzlibrary{decorations.pathmorphing}

\ParacolRuleSetup{
  custom-line={
    \draw[
      line width=.8pt,
      decorate,
      decoration={
        snake,
        amplitude=2pt,
        segment length=8pt
      }
    ] (TOP) -- (BOT);
  }
}
\end{SourceCode}

\begin{OutPut}{Output}[TikZ renderer]
\begingroup
\setlength{\columnseprule}{1pt}
\ParacolRuleSetup{
  custom-line={
    \draw[
      line width=.8pt,
      decorate,
      decoration={snake,amplitude=2pt,segment length=8pt}
    ] (TOP) -- (BOT);
  }
}
\par\noindent\hbox to \linewidth{
  \DemoColumn{.62\linewidth}{
    \textbf{Main stream}\par
    TikZ receives the exact top and bottom nodes of every separator segment.
  }
  \hfil\RuleSegment[purple!75!black]{42pt}\hfil
  \DemoColumn{.27\linewidth}{
    \textbf{Commentary}\par
    Any TikZ path can connect them.
  }
}
\par\endgroup
\end{OutPut}

TikZ 罫線は共有罫線ボックスを作成した時点の \Cmd{colseprulecolor} を使います。\Pkg{paracol} は完成した1個の罫線ボックスを各段間で再利用するため、段間ごとの色指定は標準スタイルにのみ適用されます。

A TikZ rule uses the ordinary \Cmd{colseprulecolor} active when the shared separator box is built. Because \Pkg{paracol} reuses one completed separator box for every gap, per-gap colors apply only to the built-in styles.

\section{Custom TeX Renderers}

\paragraph{Japanese}
TikZ を使わずに描画を差し替える場合は、\Cmd{ParacolRuleSetRenderer}\Code{\{\textbackslash YourMacro\}} を使います。マクロは拡張量を反映した罫線区間の高さを唯一の引数として受け取ります。返す内容はその高さを占有し、通常は \Cmd{columnseprule} の幅に収めます。

\paragraph{English}
Use \Cmd{ParacolRuleSetRenderer}\Code{\{\textbackslash YourMacro\}} to install a renderer without TikZ. The macro receives the segment height after extensions as its only argument. Its output must occupy that height and should normally fit within \Cmd{columnseprule}.

\begin{SourceCode}{Input}{TeX}
\newcommand\MyRule[1]{
  \hbox to \columnseprule{
    \vrule width .25\columnseprule height #1
    \hfil
    \vrule width .25\columnseprule height #1
  }
}

\ParacolRuleSetRenderer{\MyRule}
\end{SourceCode}

\section{Compatibility and Caution}

\paragraph{Japanese}
\Pkg{paracol} は罫線描画を差し替える公開フックを提供していないため、\Pkg{paracolrule} 0.1.0 は \Pkg{paracol} 1.37 の内部にある2か所の罫線生成処理を検査して置換します。想定した処理が見つからない場合は、中途半端な罫線を出さず読み込み時にエラーで停止します。\Pkg{paracol} を更新した場合は、同梱テストを再実行してください。

\Cmd{columnseprule} が 0pt なら、\Pkg{paracol} 標準どおり罫線を描きません。指定された印を2個置けないほど短い区間では、上下端を別々の印にできないため1本の実線へフォールバックします。

\paragraph{English}
\Pkg{paracol} does not provide a public hook for replacing its separator renderer. Version 0.1.0 therefore verifies and patches two rule-building internals from \Pkg{paracol} 1.37. If either expected operation is missing, the package stops at load time instead of drawing a partial or misplaced rule. Rerun the included tests after updating \Pkg{paracol}.

A zero \Cmd{columnseprule} suppresses rules as usual. If a segment is too short to contain two requested marks, it falls back to one solid segment because distinct endpoint marks cannot fit.

\section{License}

Released under the \LaTeX{} Project Public License 1.3c or later.

\section{Version History}

\begin{description}
  \item[v0.1.0 (2026/08/22)] Initial public version with solid, dashed, dotted, double, custom TeX, and optional TikZ renderers.
\end{description}

\end{document}
