blob: e96b6aabcb4b8e527fe92c98deda1908ccd88ed8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
#!/bin/bash
#
# lpsmag CONFIGFILE
#
# creates a LaTeX file for the production
# a Sudoku magazine with lpsudoku.sty
#
# License: LPPL
#
VERSION="v1.1 (06/05/2013)"
CONFIGFILE="$1"
TEXFILE="lpsmag.tex"
TEXFILEBAK="${TEXFILE}.bak"
typeset -i COUNT=0
SUDOKUPP="6"
SUDOKUPPD="12"
#
if [ -z "$CONFIGFILE" ]
then
echo "no config file"
echo "Usage: `basename $0` configfile"
exit 1
fi
#
exec 1> $TEXFILE
#
startpuzzles()
{
echo "\lpsudokusetup{scale=0.75,width=6.8cm,fontsize=Large,cvoffset=-24pt}"
echo "\setpuzzlecounter{1}"
}
#
startsolutions()
{
echo "\lpsudokusetup{scale=0.5,width=4.6cm,fontsize=normalsize}"
echo "\setpuzzlecounter{1}"
}
#
page()
{
local name="$1"
local difficulty="$2"
qqwing --generate $SUDOKUPP --one-line --difficulty $difficulty >${name}.81
cat ${name}.81 | qqwing --solve --one-line >${name}_sol.81
}
#
typesetpage()
{
local name="$1"
local last="$2"
local puzzlenummer="uneven"
COUNT=0
echo "%startpage"
for puzzle in `cat ${name}.81`
do
((COUNT++))
echo $puzzle >puzzle.81
createlpsudoku -i puzzle.81
if [ "$puzzlenummer" = "uneven" ]
then
echo "\hfill"
# toggle even/uneven
puzzlenummer="even"
else
# no \vfill after last lpsudoku
# environment of the page
if [ $COUNT -lt $SUDOKUPP ]
then
echo "\vfill"
else
if [ "$last" != "last" ]
then
echo "\clearpage"
fi
fi
puzzlenummer="uneven"
fi
done
}
#
tspfor()
{
local name="$1"
local last="$2"
local puzzlepos="one"
for puzzle in `cat ${name}.81`
do
((COUNT++))
if [ $COUNT -eq 1 -o $COUNT -eq 7 ]
then
echo "%startpage"
fi
echo $puzzle >puzzle.81
createlpsudoku -i puzzle.81
if [ "$puzzlepos" = "one" ]
then
echo "\hfill"
puzzlepos="two"
elif [ "$puzzlepos" = "two" ]
then
echo "\hfill"
puzzlepos="three"
else
if [ $COUNT -lt $SUDOKUPPD ]
then
echo "\vfill"
puzzlepos="one"
else
if [ "$last" = "last" ]
then
puzzlepos="one"
else
echo "\clearpage"
puzzlepos="one"
fi
fi
fi
done
}
#
typesetsolpage()
{
local name1="$1_sol"
local name2="$2_sol"
local last="$3"
COUNT=0
tspfor $name1 $last
tspfor $name2 $last
}
#
addcounterstyle()
{
grep -ne'startpage' $TEXFILE | cut -d':' -f1 >csl.tmp
for linenumber in `cat csl.tmp`
do
COUNT="$linenumber"
((COUNT++))
echo "$COUNT a [counterstyle=left]" >>sed.tmp
echo "$linenumber d" >>sed.tmp
done
sed -f sed.tmp $TEXFILE >$TEXFILEBAK
rm $TEXFILE
mv $TEXFILEBAK $TEXFILE
}
#
addpercent()
{
sed -e's/$/%/' $TEXFILE >$TEXFILEBAK
rm $TEXFILE
mv $TEXFILEBAK $TEXFILE
}
#
deleteauxfiles()
{
rm *.81
rm *.tmp
}
#
cat >preamble.tmp <<EOF
\documentclass[a4paper]{article}%
\usepackage[bottom=3cm,top=3cm,left=2.7cm,right=2.7cm]{geometry}
\usepackage{logicpuzzle}%
\lpsudokusetup{width=5cm,scale=0.55,fontsize=normalsize}%
EOF
#
cat preamble.tmp
echo "\begin{document}"
#
. $CONFIGFILE
#
echo "\end{document}"
#
addcounterstyle
addpercent
deleteauxfiles
exit 0
#
|