This is bash­script is the main work­ing horse of the makeart poster­pro­duc­tion. I tried to clean it out for the doc­u­men­ta­tion here, since I realised that in the orig­i­nal script is a lot of code, which became unnec­es­sary dur­ing the design process. For exam­ple we planned in the begin­ning to place the logo flex­i­ble inside the 3x3 grid. This was skipped at some point, because it was impos­si­ble this way, to gain the des­ig­nated size for the logo. I will go through the script step by step and hope it will be com­pre­hen­si­ble in some way.

Sup­ply­ing with Arguments

Read more here about we sup­ply the script with some arguments

Ele­ments

The posters con­sist of dif­fer­ent parts (logo, spon­sors, infor­ma­tion, gen­er­ated graph­ics) which are lay­outed with some help from LaTeX, To pro­duce graph­ics that will be used for the illus­tra­tive part of the posters, we use sep­a­rate scripts. These gen­er­a­tor scripts are stored in a folder and ran­domly selected accord­ing to the cur­rent $GRIDNUMBER–vari­able. The suit­abil­ity depends on the out­put com­plex­ity and file­size and is stored in the header sec­tion of the scripts, e.g. # SUITABLE FOR FOLLOWING GRIDS:,9,81,729,
We search via grep for gen­er­a­tor scripts, which include a line that matches the pat­tern .*SUITABLE.*,$GRIDTYPE. The option -H prints the filepath of match­ing files (sep­a­rated by a :). We sep­a­rate the filepath from the search pat­tern with cut -d ":" -f 1, select one ran­dom line with rl --count=1 and print the file­name only (with­out path): cut -d "/" -f 2.

WHITECHECK=`grep "WHITE LOGO" i/$CANVASSCRIPT | wc -l`
BLACKCHECK=`grep "BLACK LOGO" i/$CANVASSCRIPT | wc -l`
 
if [ $BLACKCHECK -ge 1 ]; then LOGO=$LOGODIR/makeartwtf_black.pdf elif [ $WHITECHECK -ge 1 ]; then LOGO=$LOGODIR/makeartwtf_white.pdf else LOGO=`ls $LOGODIR/makeartwtf_*.pdf | rl --count=1` fi
 
LCOLOR=`echo ${LOGO##*makeartwtf_}` INPUTFILE=`cat $LOGODIR/${LCOLOR%.*}.list | \ rl --count=1`
 
echo $INPUTFILE > $TMP/file.i

In this step we define the logo. We can choose between a black and a white logo. Which logo for which script depends on the amount of black of its out­put. It was decided and noted in advance in the script header. To find out about the pref­ered color we search for cer­tain string (in this case I WANT A BLACK LOGO !!!)) with grep "BLACK LOGO" i/$CANVASSCRIPT | wc -l. If there is no pref­ered color we decide ran­domly. Some of the gen­er­a­tor scripts use exist­ing vec­tor graph­ics as input. These input files are depen­dent on the cho­sen logo color and defined in a list (black or white).

Nam­ing and checking

The name of the final poster is put together from gen­er­a­tor script, grid type and logo posi­tion (The logo posi­tion dis­tinc­tion is a relict when there where 9 dif­fer­ent posi­tions, one for each grid). In the next step we test if there is already exist­ing a poster with the same con­fig­u­ra­tion. If there is already exist­ing a poster match­ing the name (= match­ing the con­fig­u­ra­tion) the script exits. The script may exit because it is trig­gered (= run again) by another shell­sript until we have the desired amount of posters.
By the way: Although there is only one more logo posi­tion (PLACELOGO=1), we use the optional vari­able in the name (wtf_aut_0_02_081-2.pdf) to allow gen­er­a­tor scripts, that pro­duce ran­dom out­put to gen­er­ate more than 1 poster. If we find the string GENERATES RANDOM OUTPUT) in the script we just exclude the logo posi­tion vari­able from our CHECKEXIST–pat­tern.

PLACELOGO=1
 
PD=${CANVASSCRIPT%.*}_ FNA=`echo 00$GRIDTYPE| rev | cut -c 1-3 | rev`- ME=$PLACELOGO
 
CHECKRANDOM=`grep "$ISRANDOM" i/$CANVASSCRIPT | wc -l`
 
if [ $CHECKRANDOM -ge 1 ]; then CHECKEXIST=`find $OUTPUTFOLDER/$FORMAT -name "*$PD$FNA$ME*" | wc -l` else CHECKEXIST=`find $OUTPUTFOLDER/$FORMAT -name "*$PD$FNA*" | wc -l` fi
 
if [ $CHECKEXIST -lt 1 ]; then

Now that we have defined our pre­sets and checked if there is not already exist­ing a poster with this con­fig­u­ra­tion we can start the actual generating.

Get­ting things done

We change into the script direc­tory with cd, exe­cute the script and return to the main folder with cd -.
The stan­dard out­put of cd is sent to /dev/null (defined in the header with NIRVANA=/dev/null) because silence is golden

  cd i 1> $NIRVANA
  ./$CANVASSCRIPT $INPUTFILE $GRIDTYPE
  cd - 1> $NIRVANA

We set the stan­dard val­ues for count­ing and define our graphic com­mand for LaTeX includ­ing a spe­cial sec­tion (pleas­ing sec­tions are defined in the gen­er­a­tor script) and a optional border.

TEXGENERATED=$TMP/canvas.tex
COLCOUNT=3
ROWCOUNT=3
COLCOUNTTWO=3
ROWCOUNTTWO=3
MAXGRIDS=9
 
SECTOR=`grep SECTOR i/$CANVASSCRIPT | \ cut -d ":" -f 2 |\ rl --count=1` BORDER=`grep BORDER i/$CANVASSCRIPT | head -1 | cut -d ":" -f 2` BORDER=\{$BORDER\}
 
############################ # GRAFIK COMMAND FOR LATEX # ############################
 
createGRAFIK () {
 
GRAFIKOPEN="\canvasgraphic{" GRAFIKCLOSE="}%"
 
O=$GRAFIKOPEN; G=$GRAFIK C=$GRAFIKCLOSE ; S=$SECTOR; W=$WIDTH
 
echo $O$G$C >> $TEXGENERATED echo $S$W >> $TEXGENERATED echo $BORDER >> $TEXGENERATED }
 
####################################

In the next steps we write the tex file which will be included in our main tex file. We dis­tinct between the 3 grids. Sim­plest grid is 3*3=9.

Dif­fer­ent Grids

  if [ $GRIDTYPE -eq 9 ]; then

We set the counts to 1 and write the vari­ables that define the lengths in the tex file.

  GRIDCOUNT=1
  GRAFIKCOUNT=1
 
echo "\setlength{\unitlength}%" > $TEXGENERATED echo "{\universalgrid}%" >> $TEXGENERATED echo "\grid%" >> $TEXGENERATED

While the GRIDCOUNT is less than our max­i­mum amount of grids we select one of the pre­vi­ously gen­er­ated pdf files, each step one file fur­ther, and write the graphic com­mand with the appro­pri­ate path into the tex file.

  while [ $GRIDCOUNT -le $MAXGRIDS ]
   do
        echo "{%"                     >> $TEXGENERATED
 
GRAFIK=`ls $TMP/*.pdf | \ head -n $GRIDTYPE | \ head -n $GRAFIKCOUNT | \ tail -1` WIDTH="{width=.97\universalgrid}"
 
createGRAFIK
 
echo "}%" >> $TEXGENERATED
 
GRIDCOUNT=`expr $GRIDCOUNT + 1` GRAFIKCOUNT=`expr $GRAFIKCOUNT + 1` done

Here you can read a bit more about the list­ing method using head and tail

Our cus­tom LateX grid macro can be sup­plied with a list of graph­ics and will auto­mat­i­cally arrange them to our usual read­ing habit:
right to left, line­break and again

This pre­scrip­tion made it a bit more com­pli­cated to place grids inside the grid.
If we use the same list­ing logic the visual order gets messed up.

If we place a grid in the grid (instead of graph­ics) and want to keep the visual order, we have to change the list­ing rou­tine. We can’t sim­ply write an ordered list into the LaTeX grid, but we have to dif­fer­en­ti­ate at cer­tain points.

elif [ $GRIDTYPE -eq 81 ]; then
 
GRIDCOUNT=1 GRAFIKCOUNT=1
 
echo "\setlength{\unitlength}%" > $TEXGENERATED echo "{\universalgrid}%" >> $TEXGENERATED echo "\grid%" >> $TEXGENERATED
 
while [ $GRIDCOUNT -le $MAXGRIDS ] do GRIDCOUNTTWO=1
 
echo "{%" >> $TEXGENERATED
 
echo "\setlength{\unitlength}%" >> $TEXGENERATED echo "{.33\universalgrid}%" >> $TEXGENERATED echo "\grid%" >> $TEXGENERATED
 
while [ $GRIDCOUNTTWO -le $MAXGRIDS ] do if [ $COLCOUNT -le 0 ]; then
 
COLCOUNT=3 GRAFIKCOUNT=`expr $GRAFIKCOUNT + 6` fi echo "{%" >> $TEXGENERATED
 
GRAFIK=`ls $TMP/*.pdf | head -n $GRIDTYPE | \ head -n $GRAFIKCOUNT | \ tail -1` WIDTH="{width=.3\universalgrid}" createGRAFIK
 
echo "}%" >> $TEXGENERATED
 
GRIDCOUNTTWO=`expr $GRIDCOUNTTWO + 1` GRAFIKCOUNT=`expr $GRAFIKCOUNT + 1` COLCOUNT=`expr $COLCOUNT - 1`
 
done
 
echo "}%" >> $TEXGENERATED
 
GRIDCOUNT=`expr $GRIDCOUNT + 1` COLCOUNT=3 ROWCOUNT=`expr $ROWCOUNT - 1`
 
if [ $ROWCOUNT -gt 0 ]; then GRAFIKCOUNT=`expr $GRAFIKCOUNT - 18` else ROWCOUNT=3 fi done

Fin­ish

Now we have to just to pre­pare the notice for the gen­er­a­tor script and ren­der the file with pdflatex.

cp $LOGO $TMP/logo.pdf
 
###################### # POSTER INFORMATION # ######################
 
cat i/$CANVASSCRIPT | \ sed 's/\#/ /g' |\ sed 's/based on/poster graphics based on/g' > $TMP/script.sh
 
######################### # DECIDE AND PLACE LOGO # #########################
 
ISPROCESSING=`grep java i/$CANVASSCRIPT | wc -l` ISSHOEBOT=`grep SHOEBOT i/$CANVASSCRIPT | wc -l`
 
if [ $ISPROCESSING -gt 0 ]; then
 
cp $LOGODIR/processing.pdf $TMP/scriptlogo.pdf
 
elif [ $ISSHOEBOT -gt 0 ]; then
 
echo TEST else cp $LOGODIR/bash.pdf $TMP/scriptlogo.pdf fi
 
pdflatex $FORMAT.tex &> $NIRVANA mv $FORMAT.pdf $OUTPUTFOLDER/$FORMAT/wtf_$PD$FNA$ME.pdf
 
else echo The File wtf_$PD$FNA$ME already exists fi
 
exit 0;