| 1 |
@echo off |
| 2 |
chcp 65001 >nul |
| 3 |
|
| 4 |
set THESIS=main |
| 5 |
set PACKAGE=hitszthesis |
| 6 |
|
| 7 |
set flag=%1 |
| 8 |
if %flag%x == x ( |
| 9 |
set flag=thesis |
| 10 |
) |
| 11 |
|
| 12 |
if %flag%x == thesisx ( |
| 13 |
call :thesis |
| 14 |
if ERRORLEVEL 1 ( |
| 15 |
echo Error! Please check the 'main.log' for more details... |
| 16 |
pause |
| 17 |
) else ( |
| 18 |
echo Finished! |
| 19 |
) |
| 20 |
goto :EOF |
| 21 |
) |
| 22 |
|
| 23 |
if %flag%x == clsx ( |
| 24 |
call :cls |
| 25 |
goto :EOF |
| 26 |
) |
| 27 |
|
| 28 |
if %flag%x == allx ( |
| 29 |
echo Compile thesis and documentation... |
| 30 |
call :doc |
| 31 |
call :thesis |
| 32 |
goto :EOF |
| 33 |
) |
| 34 |
|
| 35 |
if %flag%x == docx ( |
| 36 |
call :doc |
| 37 |
goto :EOF |
| 38 |
) |
| 39 |
|
| 40 |
if %flag%x == cleanx ( |
| 41 |
call :clean |
| 42 |
goto :EOF |
| 43 |
) |
| 44 |
|
| 45 |
if %flag%x == cleanallx ( |
| 46 |
call :cleanall |
| 47 |
goto :EOF |
| 48 |
) |
| 49 |
|
| 50 |
if %flag%x == wordcountx ( |
| 51 |
call :wordcounty |
| 52 |
goto :EOF |
| 53 |
) |
| 54 |
|
| 55 |
if %flag%x == devx ( |
| 56 |
call :doc |
| 57 |
call :thesis |
| 58 |
call :cleanall |
| 59 |
goto :EOF |
| 60 |
) |
| 61 |
|
| 62 |
:help |
| 63 |
echo This is the compile batch script for hitszhesis. |
| 64 |
echo Usage: |
| 65 |
echo compile.bat [option] |
| 66 |
echo options: |
| 67 |
echo thesis Compile the thesis (default) |
| 68 |
echo doc Compile the documentation |
| 69 |
echo all Compile the thesis and documentation |
| 70 |
echo clean Clean all work files |
| 71 |
echo cleanall Clean all work files and pdf files |
| 72 |
echo wordcount Count words in main.pdf |
| 73 |
echo help Print this help message |
| 74 |
goto :EOF |
| 75 |
|
| 76 |
:thesis |
| 77 |
echo Compile thesis... |
| 78 |
latex %PACKAGE%.ins |
| 79 |
xelatex -shell-escape %THESIS%.tex |
| 80 |
bibtex %THESIS% |
| 81 |
xelatex -shell-escape %THESIS%.tex |
| 82 |
xelatex -shell-escape %THESIS%.tex |
| 83 |
splitindex %THESIS% -- -s hitszthesis.ist |
| 84 |
xelatex -shell-escape %THESIS%.tex |
| 85 |
goto :EOF |
| 86 |
|
| 87 |
:cls |
| 88 |
echo Split cls file... |
| 89 |
xetex %PACKAGE%.ins |
| 90 |
goto :EOF |
| 91 |
|
| 92 |
:doc |
| 93 |
echo Compile documentation... |
| 94 |
latex %PACKAGE%.ins |
| 95 |
xelatex %PACKAGE%.dtx |
| 96 |
makeindex -s gind.ist -o %PACKAGE%.ind %PACKAGE%.idx |
| 97 |
makeindex -s gglo.ist -o %PACKAGE%.gls %PACKAGE%.glo |
| 98 |
xelatex %PACKAGE%.dtx |
| 99 |
xelatex %PACKAGE%.dtx |
| 100 |
goto :EOF |
| 101 |
|
| 102 |
:clean |
| 103 |
echo Clean auxiliary files... |
| 104 |
latexmk -c %PACKAGE%.dtx |
| 105 |
latexmk -c %THESIS% |
| 106 |
del *.xdv *.hd *.aux front\*.aux body\*.aux back\*.aux >nul 2>nul |
| 107 |
del main-china.idx main-english.idx >nul 2>nul |
| 108 |
goto :EOF |
| 109 |
|
| 110 |
:cleanall |
| 111 |
echo Clean class files... |
| 112 |
del %PACKAGE%.cls %PACKAGE%.cfg dtx-style.sty >nul 2>nul |
| 113 |
goto :clean |
| 114 |
goto :EOF |
| 115 |
|
| 116 |
:wordcountx |
| 117 |
set found=0 |
| 118 |
setlocal enabledelayedexpansion |
| 119 |
|
| 120 |
findstr "\\documentclass\[[^\[]*english" %THESIS%.tex > nul |
| 121 |
if %errorlevel% equ 0 ( |
| 122 |
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -char-only 2^>nul') do ( |
| 123 |
if !found! equ 1 ( |
| 124 |
echo 英文字符数: !%%i! |
| 125 |
goto :total |
| 126 |
) |
| 127 |
echo %%i | findstr "total" > nul && set found=1 |
| 128 |
) |
| 129 |
) else ( |
| 130 |
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -ch-only 2^>nul') do ( |
| 131 |
if !found! equ 1 ( |
| 132 |
echo 纯中文字数: !%%i! |
| 133 |
goto :total |
| 134 |
) |
| 135 |
echo %%i | findstr "total" > nul && set found=1 |
| 136 |
) |
| 137 |
) |
| 138 |
|
| 139 |
:total |
| 140 |
set found=0 |
| 141 |
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -chinese 2^>nul') do ( |
| 142 |
if !found! equ 1 ( |
| 143 |
echo 总字数^(英文单词+中文字^):!%%i! |
| 144 |
goto :EOF |
| 145 |
) |
| 146 |
echo %%i | findstr "total" > nul && set found=1 |
| 147 |
) |
| 148 |
goto :EOF |
| 149 |
|
| 150 |
:wordcounty |
| 151 |
texcount %THESIS%.tex -inc -chinese |
| 152 |
goto :EOF |