
私は(ほんの少し)改変したコードを使用していますこの答えポリオミノをレンダリングします。2 つの問題を除いて、うまく機能します。
1 行だけのポリオミノの長さは考慮されていないようです。
2 番目の問題は、間隔を正しく設定するために、常に最初の行をスペーサーで埋める必要があることです。(これは不便なだけなので、最初の問題ほど重大ではありません)。
これを修正する方法を知っている人はいますか?
以下に最小限の例を示します。
\documentclass{article}
\makeatletter
\def\omino#1{{%
\unitlength6\p@
\@tempcnta\z@
\@tempcntb\@ne
\count@\z@
\xomino#1\relax
\begin{picture}(\@tempcnta,\@tempcntb)(0,-\@tempcntb)%
\@tempcnta\z@
\@tempcntb\@ne
\count@\z@
\xxomino#1\relax
\end{picture}%
}%
}
\def\xomino#1{%
\ifx\relax#1%
\else
\ifx\\#1%
\ifnum\count@>\@tempcnta \@tempcnta\count@\fi
\advance\@tempcntb\@ne
\count@\z@
\else
\advance\count@\@ne
\fi
\expandafter\xomino
\fi}
\def\xxomino#1{%
\ifx\relax#1%
\else
\ifx\\#1%
\advance\@tempcntb\@ne
\count@\z@
\else
\advance\count@\@ne
\ifx*#1%
\put(\count@,-\@tempcntb){\kern-6pt\framebox(0.93,0.93)}
\fi
\fi
\expandafter\xxomino
\fi}
\makeatother
\begin{document}
Polyominoes with two or more rows like this \omino{*****\\*\\*}
work great, but polyominoes that have only one row like this
\omino{******} don't align properly.
Also, the first row needs to be complete, like this \omino{*...\\****}
to work. Without the empty characters, the polyomino is not spaced
correctly, like \omino{*\\****}this.
\end{document}
答え1
問題は、最大水平ステップの計算で最後の行が考慮されないことです。ケースの最大計算を\\
ケースに追加することでこれを修正できます\relax
。変更は でマークされています%<-
。
\documentclass{article}
\makeatletter
\def\omino#1{{%
\unitlength6\p@
\@tempcnta\z@
\@tempcntb\@ne
\count@\z@
\xomino#1\relax
\begin{picture}(\@tempcnta,\@tempcntb)(0,-\@tempcntb)%
\@tempcnta\z@
\@tempcntb\@ne
\count@\z@
\xxomino#1\relax
\end{picture}%
}%
}
\def\xomino#1{%
\ifx\relax#1%
\ifnum\count@>\@tempcnta \@tempcnta\count@\fi%<-
\else
\ifx\\#1%
\ifnum\count@>\@tempcnta \@tempcnta\count@
\fi
\advance\@tempcntb\@ne
\count@\z@
\else
\advance\count@\@ne%
\fi
\expandafter\xomino
\fi}
\def\xxomino#1{%
\ifx\relax#1%
\else
\ifx\\#1%
\advance\@tempcntb\@ne
\count@\z@
\else
\advance\count@\@ne
\ifx*#1%
\put(\count@,-\@tempcntb){\kern-6pt\framebox(0.93,0.93)}
\fi
\fi
\expandafter\xxomino%
\fi}
\makeatother
\begin{document}
Polyominoes with two or more rows like this \omino{*****\\*\\*}
work great, but polyominoes that have only one row like this
\omino{******} don't align properly.
Also, the first row needs to be complete, like this \omino{*...\\****}
to work. Without the empty characters, the polyomino is not spaced
correctly, like \omino{*\\****} this.
\end{document}