
나는이 답변폴리오미노를 렌더링합니다. 두 가지 문제를 제외하고는 훌륭하게 작동합니다.
한 줄만 있는 폴리오미노의 길이는 고려되지 않은 것 같습니다.
두 번째 문제는 간격이 올바르게 작동하려면 항상 첫 번째 행을 스페이서로 채워야 한다는 것입니다. (이것은 불편을 끼칠 뿐이므로 첫 번째 문제만큼 중요하지는 않습니다.)
이 문제를 어떻게 해결할 수 있는지 아는 사람 있나요?
다음은 최소한의 예입니다.
\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}