%# -*- coding: utf-8 -*-
\ifx\epTeXinputencoding\undefined\else % defined in e-pTeX (> TL2016)
  \epTeXinputencoding utf8    % ensure utf-8 encoding for platex
\fi

\documentclass[a4paper,dvipdfmx,english]{jsarticle}
\usepackage{doc}
\xspcode"5C=3  % \
\xspcode"3C=3  % <
\xspcode"3E=3  % >
\usepackage{plautopatch}% load this here to make \GetFileInfo work
\GetFileInfo{plautopatch.sty}
\title{Package \textsf{plautopatch} \fileversion}
\author{Hironobu Yamashita}
\date{\filedate}
\begin{document}

\maketitle

Japanese \pLaTeX/\upLaTeX\ formats and packages often conflict
with other \LaTeX\ packages which are unaware of \pLaTeX/\upLaTeX.
In the worst case, such packages throw a fatal error or
end up with a wrong output.

The goal of this package \textsf{plautopatch} is that
there should be no need to worry about such incompatibilities,
because specific patches are loaded automatically
whenever necessary.
This helps not only to simplify source files, but also
to make the appearance of working \pLaTeX/\upLaTeX\ sources
similar to those of ordinary \LaTeX\ ones.

The package is maintained on GitHub:
\begin{verbatim}
    https://github.com/aminophen/plautopatch
\end{verbatim}

\section*{Requirements}

If \LaTeXe~2020-10-01 or newer is running,
this package uses the new hook system such as
\verb+\AddToHook{package/.../before}+ and
\verb+\AddToHook{package/.../after}+.
If \LaTeXe\ is older than that, this package depends on
\textsf{filehook} package (written by Martin Scharrer).

\section*{Usage}

Load this package at the very beginning of the \LaTeX\ source.
It is strongly recommended to use
\verb+\RequirePackage{plautopatch}+
before \verb+\documentclass+ or any other commands,
as such other classes and packages may load
some problematic packages internally.

Here is an example:
\begin{verbatim}
  %\RequirePackage{plautopatch}
  \documentclass{tarticle}% vertical writing (requires plext)
  \usepackage{array}% incompatible with plext
  \begin{document}
  ...
  \end{document}
\end{verbatim}
In the above example, the class \textsf{tarticle} internally
requires the package \textsf{plext}.
However, \textsf{array} explicitly required by \verb+\usepackage+
conflicts with \textsf{plext}.
By using \verb+\RequirePackage{plautopatch}+,
\textsf{plextarray} is automatically loaded and the problem goes.
The list of automatically-loaded packages is shown at
\verb+\end{document}+:
\begin{verbatim}
***** List of packages loaded by `plautopatch': *****
 plextarray.
*****************************************************
\end{verbatim}
When multiple packages are loaded, they are all printed
as a list separated by commas and spaces.

\section*{List of currently available patches}

\def\ITEMoTo#1 (#2) -> #3 (#4){%
  \item \textsf{#1} (\textsf{#2})\\
    $\rightarrow$ \textsf{#3} (\textsf{#4})}
\def\ITEMoTx#1 (#2) -> #3 {%
  \item \textsf{#1} (\textsf{#2})\\
    $\rightarrow$ \textsf{#3} }
\def\ITEMxTo#1      -> #2 (#3){%
  \item \textsf{#1}\\
    $\rightarrow$ \textsf{#2} (\textsf{#3})}
\def\ITEMxTx#1      -> #2 {%
  \item \textsf{#1}\\
    $\rightarrow$ \textsf{#2} }
\def\ITEMooTo#1 (#2) + #3 (#4) -> #5 (#6){%
  \item \textsf{#1} (\textsf{#2}) + \textsf{#3} (\textsf{#4})\\
    $\rightarrow$ \textsf{#5} (\textsf{#6})}
\def\ITEMxoTo#1      + #2 (#3) -> #4 (#5){%
  \item \textsf{#1}               + \textsf{#2} (\textsf{#3})\\
    $\rightarrow$ \textsf{#4} (\textsf{#5})}
\def\ITEMxoTx#1      + #2 (#3) -> #4 {%
  \item \textsf{#1}               + \textsf{#2} (\textsf{#3})\\
    $\rightarrow$ \textsf{#4} }

The legend:
\begin{itemize}
\item \texttt{<original package>} (\texttt{<bundle name of original package>})\\
  \texttt{<patch package>} (\texttt{<bundle name of patch package>})
\end{itemize}

Current version (\filedate\space\fileversion) supports the followings:
\begin{itemize}
\ITEMoTo  doc (latex) -> pldocverb (platex-tools)
\ITEMoTo  tracefnt (latex) -> ptrace/uptrace (platex/uplatex)
\ITEMoTo  fltrace (latex) -> pfltrace (platex)
\ITEMoTo  array (latex-tools) -> plarray (platex-tools)
\ITEMooTo array (latex-tools) + plext (platex) -> plextarray (platex-tools)
\ITEMooTo delarray (latex-tools) + plext (platex) -> plextdelarray (platex-tools)
\ITEMxoTo colortbl + plext (platex) -> plextcolortbl (platex-tools)
\ITEMxTx  arydshln -> plarydshln (maintained here!)
\ITEMxoTx arydshln + plext (platex) -> plextarydshln (maintained here!)
\ITEMxTx  siunitx -> plsiunitx (maintained here!)
\ITEMxTx  collcell -> plcollcell (maintained here!)
\ITEMoTo  everysel (ms) -> pxeverysel (platex-tools)
\ITEMoTo  everyshi (ms) -> pxeveryshi (platex-tools)
\ITEMoTo  atbegshi (oberdiek) -> pxatbegshi (platex-tools)
\ITEMoTo  ftnright (latex-tools) -> pxftnright (platex-tools)
\ITEMoTo  multicol (latex-tools) -> pxmulticol (platex-tools)
\ITEMoTo  xspace (latex-tools) -> pxxspace (platex-tools)
\ITEMxTo  textpos -> pxtextpos (gentombow)
\ITEMxTo  eso-pic -> pxesopic (gentombow)
\ITEMxTo  pdfpages -> pxpdfpages (gentombow)
\ITEMoTo  stfloats (sttools) -> pxstfloats (pxsttools)
\ITEMxTx  hyperref -> pxjahyper (by Takayuki YATO)
\ITEMoTx  pgfrcs (pgf) -> pxpgfrcs (maintained here!)
\ITEMoTx  pgfcore (pgf) -> pxpgfmark (by Takayuki YATO)
\end{itemize}
Note that, of course, the list may be adjusted
(addition, deletion or replacement)
in the future to get the expected result.
Feel free to report some compatibility issue or request changes!

\section*{Disabling a specific patch}

By default, \texttt{<patch package>} is automatically loaded when
\texttt{<original package>} is detected, following the whole list.
However, there is still a possibility of another regression issue.
In that case, you can disable the detection of
\texttt{<original package>} by using the command:
\begin{verbatim}
    \plautopatchdisable{<original package>}
\end{verbatim}
If you want to disable multiple packages, you can give
a comma-separated list of them:
\begin{verbatim}
    \plautopatchdisable{<original package 1>,<original package 2>}
\end{verbatim}

\section*{Package-specific notice}

\begin{itemize}
  \item If you use the \textsf{hyperref} package, the patch package
    \textsf{pxjahyper} is loaded \emph{immediately} after \textsf{hyperref}.
    If you need some explicit options of \textsf{pxjahyper} (though
    it should be rare enough because it works almost perfectly without those),
    you should write \verb+\PassOptionsToPackage{...}{pxjahyper}+
    before \textsf{hyperref} to avoid an option clash.
\end{itemize}

\section*{Change History}

\begin{itemize}
  \item 2018/08/21 v0.2  First CTAN release
  \item 2018/08/22 v0.3  Improve detection of problematic packages
  \item 2018/09/21 v0.5  Add support for \textsf{colortbl} and \textsf{pgf}
  \item 2018/10/02 v0.6  Add support for \textsf{arydshln}
  \item 2018/10/27 v0.8  Better support for \textsf{everysel}
  \item 2018/11/03 v0.9  Add support for \textsf{siunitx}
  \item 2018/11/25 v0.9b Add support for \textsf{multicol} and \textsf{doc}
  \item 2019/06/06 v0.9c Update patch for \textsf{siunitx}
  \item 2019/09/05 v0.9d Add support for \textsf{xspace} and \textsf{stfloats}
  \item 2020/02/25 v0.9e Add support for \textsf{textpos}
  \item 2020/05/05 v0.9f Add support for \textsf{collcell}
  \item 2020/05/25 v0.9g Automatically load \textsf{pxjahyper}
  \item 2020/09/13 v0.9h No dependency for \textsf{filehook} on \LaTeXe~2020-10-01
  \item 2020/09/25 v0.9i Do not require \textsf{pxeveryshi} and \textsf{pxatbegshi} on \LaTeXe~2020-10-01
  \item 2020/09/27 v0.9j Add support for \textsf{eso-pic} (\LaTeXe~2020-10-01 required)
  \item 2020/10/14 v0.9k Move tombow-related patches to \textsf{gentombow}
  \item 2020/10/21 v0.9l Bug fix for \verb+\plautopatchdisable+
  \item 2020/11/26 v0.9m Adapt to latest \textsf{pgf}
  \item 2021/02/13 v0.9n Do not require \textsf{pxeverysel} on \LaTeXe~develop
  \item 2021/05/15 v0.9o Do not delay \textsf{pxjahyper} loading
  \item 2021/05/31 v0.9p Prepare for \LaTeXe~2021-06-01
  \item 2021/12/07 v0.9q Adjust for \LaTeXe~2021-11-15
\end{itemize}

\end{document}
