1

There are two main problems with the source/output pair of mine below (which is meant to be used for Hex games listings) :

1) In my printout at least, there's an unnecessary left margin and a top margin (I don't know where they come from) so the right and bottom part get eaten out.

2) My ugly 11-line code snippet whose intended meaning is a loop on a-b-c-...-k can surely can be replaced by a one-line smart loop ?

Any ideas on how to fix those issues ?

\documentclass{article}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{pifont}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage[a4paper,nohead,nofoot]{geometry}

\addtolength{\textwidth}{4cm}
\addtolength{\textheight}{4cm}

\addtolength{\hoffset}{-2cm}
\addtolength{\voffset}{-2cm} 


\begin{document}

\pagestyle{empty}

\begin{tikzpicture}
\path (-1,0) coordinate (Z);
\path (Z)++(0.2,0) coordinate (Y);
\foreach \bx in {0,5.5,11,16.5}
{
\foreach \by in {0,-6,-12,-18,-24}
{
\path (Y) ++(\bx,\by)  coordinate (X);

\draw (X)  ++(0.2,0.2) node[anchor=south east] {$a$};
\draw (X)  ++(0.6,0.2) node[anchor=south east] {$b$};
\draw (X)  ++(1.0,0.2) node[anchor=south east] {$c$};
\draw (X)  ++(1.4,0.2) node[anchor=south east] {$d$};
\draw (X)  ++(1.8,0.2) node[anchor=south east] {$e$};
\draw (X)  ++(2.2,0.2) node[anchor=south east] {$f$};
\draw (X)  ++(2.6,0.2) node[anchor=south east] {$g$};
\draw (X)  ++(3.0,0.2) node[anchor=south east] {$h$};
\draw (X)  ++(3.4,0.2) node[anchor=south east] {$i$};
\draw (X)  ++(3.8,0.2) node[anchor=south east] {$j$};
\draw (X)  ++(4.2,0.2) node[anchor=south east] {$k$};
\foreach \x in {1,2,...,11}
{
\draw (X)++(\x*0.2,-\x*0.4) ++(-0.2,0.4) node[anchor=east] {$\x$};
\foreach \y in {0,0.2,...,2}
{
\draw (X) ++(-0.4,0) ++(\x*0.4,0) ++(\y,-\y*2)  -- ++(0,0.2) -- ++(0.2,0.2) -- ++(0.2,-0.2)  -- ++(0,-0.2) -- ++(-0.2,-0.2) --cycle;
}
}
}
}


\end{tikzpicture}


\end{document}

enter image description here

user40960
  • 811
  • The loop for the labels can be done via \foreach \Label [count=\X] in {a,...,k} {\draw (X) ++(-0.2+\X*0.4,0.2) node[anchor=south east] {$\Label$};}. And your picture is simply too big, you can use \usepackage[a4paper,nohead,nofoot,margin=0pt]{geometry} and remove all the \addtolengths but it won't fit. You may either scale it down or add less of these structures per page. BTW, if you want to speed things up, you could use a pattern, see e.g. https://tex.stackexchange.com/a/513715/194703. –  Nov 25 '19 at 13:24

1 Answers1

1

For the record, here's a fix following the suggestions in Schrödinger's cat's comment :

\documentclass{article}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{pifont}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage[a4paper,nohead,nofoot,margin=0pt]{geometry}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
\path (-1,0) coordinate (Z);
\path (Z)++(0.2,0) coordinate (Y);
\foreach \bx in {0,5.5,11}
{
\foreach \by in {0,-6,-12,-18,-24}
{
\path (Y) ++(\bx,\by)  coordinate (X);
\foreach \Label [count=\X] in {a,...,k} {\draw (X) ++(-0.2+\X*0.4,0.2) node[anchor=south east] {$\Label$};}
\foreach \x in {1,2,...,11}
{
\draw (X)++(\x*0.2,-\x*0.4) ++(-0.2,0.4) node[anchor=east] {$\x$};
\foreach \y in {0,0.2,...,2}
{
\draw (X) ++(-0.4,0) ++(\x*0.4,0) ++(\y,-\y*2)  -- ++(0,0.2) -- ++(0.2,0.2) -- ++(0.2,-0.2)  -- ++(0,-0.2) -- ++(-0.2,-0.2) --cycle;
}}}}
\end{tikzpicture}
\end{document}
user40960
  • 811