Skip to content

Instantly share code, notes, and snippets.

@h20y6m
Created August 28, 2021 08:19
Show Gist options
  • Save h20y6m/c805402cb3a497abf2263e01242af399 to your computer and use it in GitHub Desktop.
Save h20y6m/c805402cb3a497abf2263e01242af399 to your computer and use it in GitHub Desktop.
LaTeX: shipout/background, shipout/foreground フックの原点を補正する。
%% shipout/background, shipout/foreground フックの原点を補正する。
%\documentclass[dvipdfmx,a4j,12pt]{jarticle}
%\usepackage{bounddvi}
%\documentclass[dvipdfmx,a4j,12pt,tombow]{jarticle}
%\usepackage{bounddvi}
%\documentclass[dvipdfmx,a4j,12pt,tombow]{jarticle}
%\usepackage[pdfbox]{gentombow}
%\usepackage{bounddvi}
%\documentclass[dvipdfmx,a4paper,12pt,nomag*,papersize]{jsarticle}
%\documentclass[dvipdfmx,a4paper,12pt,nomag*,tombow,papersize]{jsarticle}
%\documentclass[dvipdfmx,a4paper,12pt,papersize]{jsarticle}
\documentclass[dvipdfmx,a4paper,12pt,tombow,papersize]{jsarticle}
%\documentclass[dvipdfmx,a4paper,12pt]{jlreq}
%\usepackage[pdfbox]{gentombow}
%\usepackage{bounddvi}
%\documentclass[a4paper,12pt]{ltjsarticle}
%\documentclass[a4paper,12pt,tombow]{ltjsarticle}
%\documentclass[lualatex,a4paper,12pt]{jlreq}
%\usepackage[pdfbox]{gentombow}
%\documentclass[autodetect-engine,dvi=dvipdfmx,ja=standard,a4paper,12pt]{bxjsarticle}
%\usepackage{bxpapersize}
%\documentclass[autodetect-engine,dvi=dvipdfmx,ja=standard,a4paper,12pt,nomag*]{bxjsarticle}
%\usepackage[pdfbox]{gentombow}
%\usepackage{bxpapersize}
% !!!!!!!! BEGIN PATCH !!!!!!!!
\usepackage{etoolbox}
\makeatletter
\ExplSyntaxOn
\legacy_if:nTF { tombow }
{
\dim_add:Nn \hoffset { 1in }
\dim_add:Nn \voffset { 1in }
}
{
\dim_add:Nn \hoffset { 1in - 1truein }
\dim_add:Nn \voffset { 1in - 1truein }
\dim_add:Nn \topmargin { 1truein - 1in }
\dim_add:Nn \oddsidemargin { 1truein - 1in }
\dim_add:Nn \evensidemargin { 1truein - 1in }
}
\ExplSyntaxOff
\patchcmd \@tombowreset@@paper
{\advance\@@topmargin 1in\relax \advance\@themargin 1in\relax}%
{}%
{}{}%
\patchcmd \@outputtombow % pLaTeX
{\kern-\dimexpr 10mm+\@tombowbleed\relax\relax}%
{\kern-\dimexpr 1in+10mm+\@tombowbleed\relax\relax}%
{}{}%
\patchcmd \@outputtombow % LuaTeX-ja
{\kern\dimexpr-10mm-\@tombowbleed\relax}%
{\kern\dimexpr-1in-10mm-\@tombowbleed\relax}%
{}{}%
\patchcmd \@outputtombow
{\moveleft\@tombowbleed \vbox to\@@paperheight}%
{\moveleft\dimexpr 1in+\@tombowbleed\relax \vbox to\@@paperheight}%
{}{}%
\patchcmd \@outputpage % LuaTeX-ja
{\iftombow\vskip1in\fi}%
{}%
{}{}%
\makeatother
% !!!!!!!! END PATCH !!!!!!!!
\AddToHook{shipout/background}{
\linethickness{0.1truemm}
\multiput(0,0)(10truemm,0){6}{\line(0,-1){50truemm}}
\multiput(0,0)(0,-10truemm){6}{\line(1,0){50truemm}}
\multiput(\paperwidth,-\paperheight)(-10truemm,0){6}{\line(0,1){50truemm}}
\multiput(\paperwidth,-\paperheight)(0,10truemm){6}{\line(-1,0){50truemm}}
}
\usepackage{bxjalipsum}
\begin{document}
\jalipsum{wagahai}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment