source: palm/trunk/SCRIPTS/compile_tutorial @ 981

Last change on this file since 981 was 981, checked in by maronga, 12 years ago

removed typos, update in img2video, added new tool img2stereo

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
1#!/bin/ksh
2#------------------------------------------------------------------------------!
3# Current revisions:
4# -----------------
5# Typo removed
6#
7# Former revisions:
8# -----------------
9# $Id: compile_tutorial 981 2012-08-09 14:57:44Z maronga $
10#
11# 915 2012-05-30 15:11:11Z maronga
12# Initial revision
13#
14# Description:
15# ------------
16# This script compiles all LaTeX files that are located in TUTORIAL/SOURCE/.
17# Three PDFs are generated for each source file:
18# the lecture version has a step-by-step layout, the handout version contains
19# lines for notes, the web version can contain additional comments by the
20# authors and has no step-by-step layout.
21# If a file is given as input parameter, only this file will be compiled.
22#
23# Execution:
24# ----------
25# compile_tutorial                 --> compiles all *.tex files in directory.
26# compile_tutorial -f filename.tex --> compiles filename.tex only.
27#------------------------------------------------------------------------------!
28
29    cycles=3
30    debug=false
31    file=""
32
33    full_name=`readlink -f $0`
34    directory="$(dirname $full_name)/../TUTORIAL/SOURCE"
35    output_dir="$(dirname $full_name)/../TUTORIAL"
36    cd $directory
37
38    while  getopts  :df: option
39    do
40       case  $option  in
41          (d)   debug=true;;
42          (f)   file=$OPTARG;;
43          (\?)  printf "\n  +++ unknown option $OPTARG \n"
44                printf "\n  --> type \"$0 ?\" for available options \n"
45                locat=parameter;exit;;
46       esac
47    done
48
49    shift OPTIND-1
50
51
52#   Print help
53    if [[ "$1" = "?" ]]
54    then
55       (printf "\n  *** compile_tutorial can be called as follows:\n"
56        printf "\n     compile_tutorial  -d  -f..\n"
57        printf "\n     Description of available options:\n"
58        printf "\n      Option      Description                                 Default-Value"
59        printf "\n        -d        show all debug output                               false"
60        printf "\n        -f        Filename (single file compilation mode)                \"\""
61        printf "\n         ?        this outline \n\n") | more
62        exit
63    fi
64
65    if [[ "$file" != "" ]] then
66       file_list=`readlink -f $(basename $file)`
67    else
68       file_list="$directory/*.tex"
69    fi
70
71
72    if [[ ! -d $output_dir/LECTURE ]] then
73       printf " $output_dir/LECTURE will be created.\n"
74       mkdir -p $output_dir/LECTURE
75    fi
76
77    if [[ ! -d $output_dir/HANDOUT ]] then
78       printf " $output_dir/HANDOUT will be created.\n"
79       mkdir -p $output_dir/HANDOUT
80    fi
81
82    if [[ ! -d $output_dir/WEB ]] then
83       printf " $output_dir/WEB will be created.\n"
84       mkdir -p $output_dir/WEB
85    fi
86
87    for i in $file_list;
88    do
89       if [[ "$(echo $(basename $i)|cut -c1-6)" != "header" ]] then
90          printf "\n Compiling $i.\ Please wait..."
91
92#         Check if file exists
93          if [[ ! -f "$i" ]] then
94             printf " error."
95             printf "\n File $i does not exist. Skipping..."
96             break
97          fi
98
99          compiling_type="LECTURE"
100          for (( j=0; j<=2; j+=1 ))
101          do
102             rm -rf tmp_dir
103             mkdir tmp_dir
104             cp header_${compiling_type}.tex header_tmp.tex
105             for (( k=1; k<=$cycles; k+=1 ))
106             do
107                if ( $debug ) then
108                   printf "\n pdflatex output:\n\n\n"
109                   pdflatex -halt-on-error -output-directory=tmp_dir $i
110                   if [[ "$?" != "0" ]] 
111                   then
112                      printf "\n\n Compilation aborted. Please check your source code.\n"
113                      rm -rf tmp_dir
114                      exit
115                    fi
116                else
117                   pdflatex -halt-on-error -output-directory=tmp_dir $i  2>&1 > error_file
118
119                   if [[ "$?" != "0" ]] 
120                   then
121                      printf " error."
122                      printf "\n The following error occured during the compilation:\n\n\n"
123                      cat error_file |grep "Error"
124                      printf "\n\n Compilation aborted. Please check your source code.\n"
125                      rm -rf tmp_dir
126                      rm error_file
127                      exit
128                   fi
129                fi
130                mv tmp_dir/*.pdf $output_dir/$compiling_type
131             done
132             if [[ "$compiling_type" = "LECTURE" ]]
133             then
134                compiling_type="WEB"
135             elif [[ "$compiling_type" = "WEB" ]]
136             then
137                compiling_type="HANDOUT"
138             fi
139          done 
140          printf " done."
141       fi
142
143#      Cleaning up
144       if [[ -f header_tmp.tex ]] then
145          rm header_tmp.tex
146       fi
147       if [[ -f error_file ]] then
148          rm error_file
149       fi
150       if [[ -d tmp_dir ]] then
151          rm -rf tmp_dir
152       fi
153
154    done
155
156    printf "\n\n *** All actions finished.\n"
157
158exit
Note: See TracBrowser for help on using the repository browser.