# taken from github SpeleoPhilippines under Creative Commons Share Alike

### index of file options from _layouts.tex
  #copy custom_colorlegendbox #borrowedstolen base from henry_bennett
  #copy custom_legendsymbolbox #borrowedstolen base from henry_bennett
 

#############################################################################################################################
layout custom_colorlegendbox
  #http://therion.speleo.sk/wiki/doku.php/tips#map-image_and_custom_legendbox
  code tex-map
	\def\colorlegendbox#1#2#3{%
	  #\setbox\xxx=\hbox to 36bp{\PL{q #1 #2 #3 rg 0 0 36 24 re f Q}\hfil}%
	  \setbox\xxx=\hbox to 125bp{\PL{q #1 #2 #3 rg 0 0 360 224 re f Q}\hfil}%
	  \ht\xxx=125bp\dp\xxx=10bp
	  #\xxx\ht{200pt}
	  \immediate\pdfxform\xxx
	}	
  endcode
endlayout

#############################################################################################################################
layout custom_legendsymbolbox
  #http://therion.speleo.sk/wiki/doku.php/tips#map-image_and_custom_legendbox
  code tex-map
	\def\legendsymbolbox#1#2{%
	  \setbox\tmpboxa=\hbox{\pdfrefxform#1}%
	  \setbox\tmpboxb=\hbox{\the\legendtextsize(}%
	  \legendsymbolwd=\wd\tmpboxa
	  \legendsymbolht=\ht\tmpboxa
	  \advance\legendsymbolht by -\ht\tmpboxb
	  \advance\legendsymbolht by -\ht\tmpboxb
	  \advance\legendsymbolht by -20pt
	  \advance\legendsymbolht by -1dd
	  \tmpdimen=\hsize
	    \advance\tmpdimen by 10pt 
	    \divide\tmpdimen by\legendcolumns 
	    \advance\tmpdimen by-10pt
	  \hbox to \tmpdimen{%
	     \box\tmpboxa\kern10pt\raise\legendsymbolht\vtop{%
	       \advance\tmpdimen by -\legendsymbolwd
	       \advance\tmpdimen by -10pt
	       \hsize=\tmpdimen\rightskip=0pt plus \tmpdimen minus 0pt\relax\the\legendtextsize #2\vskip1dd}\hss}%
	}
  endcode
endlayout

