#!/bin/sh # spectrum version 3.8 by Nick - Jun. 20, 2020 # usage: spectrum <#column where energy is stored> datafile # The default column where energy is stored is 1 # Assume that in the column immediately following energy # there is an (optional) numeric label that governs the # horizontal shift of the lines. # All the rest of the rows is taken as label tmpdir=/tmp tmpname="$tmpdir"/spectrum_tmp tmpfile="$tmpname".tex outfile="$tmpname".ps # this is the final OUTPUT FILE!! totalwidth=120 # the full portrait page is 130 totalheight=90 # the full portrait page is 200 framed=1 putlabel=1 arrow=0; # length of arrows, if 0 no arrows are drawn echo framed=$framed putlabel=$putlabel nf=1 ns="" for i in $* do case $i in [0-9]*) nf=$i ns="y" esac done for i in $ns do shift done cat << EEE > $tmpfile \documentclass[a4paper]{letter} \usepackage{graphicx} \setlength{\textwidth}{160mm} \setlength{\oddsidemargin}{3mm} \thispagestyle{empty} \begin{document} \begin{center} \setlength{\unitlength}{1mm} \begin{picture}($totalwidth,$totalheight)(0,5) EEE awk ' function abs(x){ if(x>=0){return x} else{return -x} } function hdash(y){ # draw horizontal dashed line ndash=60; dashwidth=1.*totalwidth/ndash; for(i=0;ienergy[tNR]){emin=energy[tNR]} if(emaxextran[tNR]+0){xmin=extran[tNR]+0} if(xmax-300;i--) # the range of double { if(10^i8){delscale*=2}; if(emin>0){scalemin=delscale*int(emin/delscale+1)} else {scalemin=delscale*int(emin/delscale)} for(etick=scalemin-delscale;etick0){ print "\\linethickness{0.5 pt}" print "\\put(",0,",",ypos,"){\\line(1,0){",ticklength,"}}" print "\\linethickness{0.03 pt}" # draw the thin dashes hdash(ypos) if(ypos0){ print "\\linethickness{0.01 pt}" # draw the thin dashes hdash(yposplus) } } #--------------------------------------------the actual lines------------------ print "\\linethickness{1.3 pt}" for(i=1;i<=tNR;i++){ effecwidth=totalwidth-width-2*boxtxtx if(xmax==xmin) {xpos=(totalwidth-width)*0.5} else {xpos=effecwidth/(xmax-xmin) * (extran[i]-xmin)+boxtxtx*0.5} ypos=scalefac * (energy[i]-emin) print "\\put(",xpos,",",ypos,"){\\line(1,0){",width,"}}" print "\\put(",xpos+width,",",ypos-boxtxty*0.57,"){\\makebox(",boxtxtx,",",boxtxty,")[l]{",label[i],"}}" if(al>0){ print "\\put(",xpos+width*0.46,",",ypos-al/2,"){\\vector(0,1){",al,"}}"; print "\\put(",xpos+width*0.54,",",ypos+al/2,"){\\vector(0,-1){",al,"}}"; } print "\\put(",xpos+width/2-boxtxtx/2,",",-boxtxty,"){\\makebox(",boxtxtx,",",boxtxty,")[c]{",stringlabel,extran[i],"}}" } }' $* >> $tmpfile cat << ENDD >> $tmpfile \end{picture} \end{center} \end{document} ENDD cd $tmpdir latex $tmpname dvips $tmpname -o gv $outfile & \rm $tmpname.log $tmpname.dvi $tmpname.aux