GeneralBoxes in plain TeX

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
blindax
Posts: 2
Joined: Sat Dec 01, 2012 3:09 pm

Boxes in plain TeX

Post by blindax »

Hi,

I´m new to TeX and I am trying to create a chessboard 8x8 using boxes. I use this code

Code: Select all

\hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm 

\vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax 

\hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \par

\vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax 

\hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \par

\vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax 

\hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \par

\vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax \hskip 2cm \vrule width 2cm height 2cm \relax 

\bye
My question is why is the last black square (on right side) longer? And is there a way to draw lines around every column/row to make it look like chessboard? thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Boxes in plain TeX

Post by Stefan Kottwitz »

Do you know the chessboard package? Or do you really want to create it on your own?

Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Boxes in plain TeX

Post by cgnieder »

Hi blindax,

welcome to the LaTeX community!

I'm not really sure why the last vrule isn't a square but it must have to to with the parindent since saying \parindent=0pt fixes the issue. I rarely use plain TeX so use the following at you own risk ;)

Code: Select all

\def\squarelength{2cm}
\def\white{%
  \vrule width 0pt\relax
  \vbox{%
    \hrule height .5pt\relax
    \hbox{%
      \vrule width .5pt\relax\kern\squarelength\relax\kern-1pt\relax
      \vbox{\kern\squarelength\relax\kern-1pt\relax}\vrule width.5pt\relax}%
    \hrule height .5pt\relax
  }}
\def\black{\vrule width \squarelength height \squarelength\relax}
\def\wbline{\white\black\white\black\white\black\white\black\vskip-1pt\relax}
\def\bwline{\black\white\black\white\black\white\black\white\vskip-1pt\relax}
\def\chessboard{%
  \begingroup
    \parindent=0pt\relax
    \wbline\bwline\wbline\bwline\wbline\bwline\wbline\bwline
  \endgroup}

\chessboard

\bye
Regards
site moderator & package author
blindax
Posts: 2
Joined: Sat Dec 01, 2012 3:09 pm

Re: Boxes in plain TeX

Post by blindax »

Thanks, this is exactly what i didn´t get. I knew about the package but I just wanted to do it my way.
Post Reply