diff options
author | Norbert Preining <norbert@preining.info> | 2023-03-12 03:01:58 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-03-12 03:01:58 +0000 |
commit | b3d8df92a44aa1df24a0869d728b45b0baeaa54c (patch) | |
tree | e29b1629fe0120f4d75acc0c72e9470ba7587b88 /macros/latex/contrib | |
parent | 6d29701d91e7deb368e3829e1ff11dcf483cd2fb (diff) |
CTAN sync 202303120301
Diffstat (limited to 'macros/latex/contrib')
17 files changed, 1451 insertions, 706 deletions
diff --git a/macros/latex/contrib/hfutexam/CHANGELOG.md b/macros/latex/contrib/hfutexam/CHANGELOG.md index 6a7de473b7..1e2dd6ee64 100644 --- a/macros/latex/contrib/hfutexam/CHANGELOG.md +++ b/macros/latex/contrib/hfutexam/CHANGELOG.md @@ -1,5 +1,14 @@ # 更新日志 +## [1.7] - 2023/03/10 ++ 精简了文档类的代码。 ++ 将伪粗体权重统一设置为3以更接近Word的加粗效果。 ++ 调整了标题文字的空格分布。 ++ 为`\XiZhuRenQianMing`命令添加了可选参数,以调节该图像的宽度,默认为`5em`. ++ 加入了命令`\hfutstretch`,为标题中带下划线文字两侧空格长度与各分项之间空格长度的比例,默认为`1.5`. ++ 为简易模式的各个部分添加了书签。 ++ 重新调整了标题的字体和位置。 + ## [1.6] - 2022/12/07 + `\fillblank`的默认高度现在均为`0.5cm`. diff --git a/macros/latex/contrib/hfutexam/hfutexam.cls b/macros/latex/contrib/hfutexam/hfutexam.cls index 8131526917..a8eb76dae0 100644 --- a/macros/latex/contrib/hfutexam/hfutexam.cls +++ b/macros/latex/contrib/hfutexam/hfutexam.cls @@ -7,37 +7,26 @@ % 编译模式: XeLaTeX % 你可以任意修改或再次分发该文件 \NeedsTeXFormat{LaTeX2e} -\ProvidesClass{hfutexam}[2022/12/07 v1.6 HFUTExam document class by Zhang Shenxing] -% 文档选项 shijuan, datizhi, cankaodaan, simple -\newif\ifHFUT@ShiJuan -\newif\ifHFUT@DaTiZhi -\newif\ifHFUT@CanKaoDaAn -\newif\ifHFUT@Simple -\newcommand{\setalltypefalse}{% - \HFUT@ShiJuanfalse% - \HFUT@DaTiZhifalse% - \HFUT@CanKaoDaAnfalse% - \HFUT@Simplefalse -} -\setalltypefalse\HFUT@ShiJuantrue -\DeclareOption{datizhi}{\setalltypefalse\HFUT@DaTiZhitrue} -\DeclareOption{cankaodaan}{\setalltypefalse\HFUT@CanKaoDaAntrue} -\DeclareOption{simple}{\setalltypefalse\HFUT@Simpletrue} -% 文档选项 nofangzheng -\newif\ifHFUT@Fandol\HFUT@Fandoltrue -\DeclareOption{nofangzheng}{\HFUT@Fandolfalse} +\ProvidesClass{hfutexam}[2023/03/10 v1.7 HFUTExam document class by Zhang Shenxing] +% 文档选项 +\newif\ifhfut@ShiJuan\hfut@ShiJuantrue +\newif\ifhfut@DaTiZhi\hfut@DaTiZhifalse +\newif\ifhfut@Simple\hfut@Simplefalse +\newif\ifhfut@Fandol\hfut@Fandoltrue +\DeclareOption{datizhi}{\hfut@ShiJuanfalse\hfut@DaTiZhitrue\hfut@Simplefalse} +\DeclareOption{cankaodaan}{\hfut@ShiJuanfalse\hfut@DaTiZhitrue\hfut@Simplefalse} +\DeclareOption{simple}{\hfut@ShiJuanfalse\hfut@DaTiZhifalse\hfut@Simpletrue } +\DeclareOption{nofangzheng}{\hfut@Fandolfalse} % 默认使用方正字体 % 基于 ctexart 文档类 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexart}} \ProcessOptions\relax -\ifHFUT@Simple\else\PassOptionsToClass{twocolumn}{ctexart}\fi +\ifhfut@Simple\else\PassOptionsToClass{twocolumn}{ctexart}\fi \ProcessOptions\relax \LoadClass[12pt,oneside]{ctexart} % 页面设置 -\RequirePackage{amsmath,amssymb,amsthm} -\RequirePackage{graphicx} -\RequirePackage{enumitem} -\RequirePackage{geometry} -\ifHFUT@Simple +\RequirePackage{amsmath,amssymb,amsthm, graphicx, enumitem, fancyhdr, lastpage, etoolbox, geometry, tikz, zref-savepos} +\RequirePackage[normalem]{ulem} +\ifhfut@Simple \geometry{a4paper,scale=0.8} \else \geometry{ @@ -46,24 +35,33 @@ left=3.17cm, right=3.17cm, voffset=2.2cm, - headheight=77pt, + headheight=78pt, headsep=12pt, footskip=1cm } + \setlength\columnsep{0.8cm} % 分栏间距 + \columnseprule=0.5pt % 分栏线宽度 \fi % 试卷信息 -\newcommand{\BiaoTi}[1]{\gdef\HFUT@BiaoTi{#1}} -\newcommand{\XueNian}[2]{\gdef\HFUT@XueNians{#1}\gdef\HFUT@XueNiane{#2}} -\newcommand{\XueQi}[1]{\gdef\HFUT@XueQi{#1}} -\newcommand{\KeChengDaiMa}[1]{\gdef\HFUT@KeChengDaiMa{#1}} -\newcommand{\KeChengMingCheng}[1]{\gdef\HFUT@KeChengMingCheng{#1}} -\newcommand{\XueFen}[1]{\gdef\HFUT@XueFen{#1}} -\newcommand{\KeChengXingZhi}[1]{\gdef\HFUT@KeChengXingZhi{#1}} -\newcommand{\KaoShiXingShi}[1]{\gdef\HFUT@KaoShiXingShi{#1}} -\newcommand{\ZhuanYeBanJi}[1]{\gdef\HFUT@ZhuanYeBanJi{#1}} -\newcommand{\KaoShiRiQi}[1]{\gdef\HFUT@KaoShiRiQi{#1}} -\newcommand{\MingTiJiaoShi}[1]{\gdef\HFUT@MingTiJiaoShi{#1}} -\newcommand{\XiZhuRenQianMing}[1]{\gdef\HFUT@XiZhuRenQianMing{#1}} +\newcommand{\hfutstretch}{1.5} % 下划线内两侧空格长度除以条目之间空格长度 +\newcommand{\hfutul}[1]{\uline{\hspace{\stretch{\hfutstretch}}#1\hspace{\stretch{\hfutstretch}}}} +\newcommand{\hfutrule}[1]{\rule{#1}{0mm}} +\newcommand{\hfutboxyes}{{\raisebox{-0.5mm}{\LARGE$\checkmark\hspace{-18pt}\square$}}} +\newcommand{\hfutboxno}{{\raisebox{-0.5mm}{\LARGE$\square$}}} +\newcommand{\XueNian}[2]{\gdef\hfut@XueNian{{\hfutFontTimes #1}~{\hfutFontTimes #2}}} +\newcommand{\BiaoTi}[1]{\gdef\hfut@BiaoTi{#1}} +\newcommand{\XueQi}[1]{\gdef\hfut@XueQi{#1}} +\newcommand{\XueFen}[1]{\gdef\hfut@XueFen{#1}} +\newcommand{\KeChengXingZhi}[1]{\gdef\hfut@KeChengXingZhi{#1}} +\newcommand{\KaoShiXingShi}[1]{\gdef\hfut@KaoShiXingShi{#1}} +\newcommand{\KeChengDaiMa}[1]{\gdef\hfut@KeChengDaiMa{#1}} +\newcommand{\KeChengMingCheng}[1]{\gdef\hfut@KeChengMingCheng{#1}} +\newcommand{\ZhuanYeBanJi}[1]{\gdef\hfut@ZhuanYeBanJi{#1}} +\newcommand{\KaoShiRiQi}[1]{\gdef\hfut@KaoShiRiQi{#1}} +\newcommand{\MingTiJiaoShi}[1]{\gdef\hfut@MingTiJiaoShi{#1}} +\newcommand{\XiZhuRenQianMing}[2][5em]{\gdef\hfut@XiZhuRenQianMing{% + \tikz[overlay]\node at (1.5,0.22) {\ifx#2\@empty\else\includegraphics[width=#1]{#2}\fi};% + \uline{\hspace{0.5em}\hfutrule{#1}\hspace{0.5em}}}} \BiaoTi{} \XueNian{}{} \XueQi{} @@ -77,144 +75,110 @@ \MingTiJiaoShi{} \XiZhuRenQianMing{} % 粗字体设定 -\newfontfamily\timesnewroman[AutoFakeBold={1.5}]{Times New Roman} % 粗罗马 -\ifHFUT@Fandol - \setCJKfamilyfont{titlesongti}[AutoFakeBold={1.5}]{FZXiaoBiaoSong-B05S} % 粗方正小标宋 - \newfontfamily\entitlesongti[AutoFakeBold={1.5}]{FZXiaoBiaoSong-B05S} - \setCJKfamilyfont{titlefangsong}[AutoFakeBold={1.5}]{FZFangSong-Z02S} % 粗方正仿宋 - \newfontfamily\entitlefangsong[AutoFakeBold={1.5}]{FZFangSong-Z02S} +\newfontfamily\hfutFontTimes[AutoFakeBold={3}]{Times New Roman} % 粗罗马 +\ifhfut@Fandol + \setCJKfamilyfont{hfutFontTitle}[AutoFakeBold={3}]{FZXiaoBiaoSong-B05S} % 粗方正小标宋 + \newfontfamily\hfutFontTitleEn[AutoFakeBold={3}]{FZXiaoBiaoSong-B05S} + \setCJKfamilyfont{hfutFontHead}[AutoFakeBold={3}]{FZFangSong-Z02S} % 粗方正仿宋 + \newfontfamily\hfutFontHeadEn[AutoFakeBold={3}]{FZFangSong-Z02S} \else - \setCJKfamilyfont{titlesongti}[AutoFakeBold={4}]{NSimSun} % 粗新宋体 - \newfontfamily\entitlesongti[AutoFakeBold={4}]{NSimSun} - \setCJKfamilyfont{titlefangsong}[AutoFakeBold={1.5}]{FangSong} % 粗仿宋 - \newfontfamily\entitlefangsong[AutoFakeBold={1.5}]{FangSong} + \setCJKfamilyfont{hfutFontTitle}[AutoFakeBold={3}]{NSimSun} % 粗新宋体 + \newfontfamily\hfutFontTitleEn[AutoFakeBold={3}]{NSimSun} + \setCJKfamilyfont{hfutFontHead}[AutoFakeBold={3}]{FangSong} % 粗仿宋 + \newfontfamily\hfutFontHeadEn[AutoFakeBold={3}]{FangSong} \fi -\newcommand{\titlesongti}{\entitlesongti\CJKfamily{titlesongti}} -\newcommand{\titlefangsong}{\entitlefangsong\CJKfamily{titlefangsong}} -\setCJKfamilyfont{xinsongti}[AutoFakeBold={1.5}]{NSimSun} % 粗新宋体 -\newfontfamily\enxinsongti[AutoFakeBold={1.5}]{NSimSun} -\newcommand{\xinsongti}{\enxinsongti\CJKfamily{xinsongti}} -\setCJKfamilyfont{cusongti}[AutoFakeBold={1.5}]{SimSun} % 粗宋体 -\newcommand{\cusongti}{\CJKfamily{cusongti}} +\newcommand{\hfutFontTitle}{\CJKfamily{hfutFontTitle}\hfutFontTitleEn} +\newcommand{\hfutFontHead}{\hfutFontHeadEn\CJKfamily{hfutFontHead}} % 重新设定字体大小 -\renewcommand{\LARGE}{\fontsize{21}{21}} -\renewcommand{\large}{\fontsize{14}{14}} -\renewcommand{\normalsize}{\fontsize{12}{12}} -\renewcommand{\small}{\fontsize{10.5}{10.5}} +\renewcommand{\LARGE}{\fontsize{21pt}{25.2pt}} +\renewcommand{\large}{\fontsize{14pt}{21pt}} +\renewcommand{\small}{\fontsize{10.5pt}{12.6pt}} % 缩进 \setlength{\parindent}{0em} \renewcommand{\indent}{\hspace*{2em}} -% 分栏 -\setlength\columnsep{0.8cm} % 分栏间距 -\columnseprule=0.5pt % 分栏线宽度 % 页眉页脚 -\RequirePackage{fancyhdr} -\RequirePackage{lastpage} -\RequirePackage{etoolbox} -\renewcommand\headrulewidth{0.5pt} % 页眉线宽度 -\renewcommand\footrulewidth{0.5pt} % 页脚线宽度 \pagestyle{fancy} \fancyhf{} -\newcommand{\boxyes}{{\raisebox{-0.5mm}{\LARGE$\checkmark\hspace{-1.2em}\square$}}} -\newcommand{\boxno}{{\raisebox{-0.5mm}{\LARGE$\square$}}} -\newcommand{\filltitle}[2]{\uline{\makebox[#1]{#2}}} -\newlength{\ltitle} -\settowidth{\ltitle}{\HFUT@BiaoTi} -\ifHFUT@ShiJuan%试卷页眉页脚 - \fancyhead[C]{% - \hfill\bfseries\LARGE\titlesongti\ifdimcomp\ltitle>{0.5\linewidth}{\HFUT@BiaoTi}{\makebox[0.5\linewidth][s]{\HFUT@BiaoTi}}\hfill% - \large\cusongti 共\filltitle{1.5em}{\timesnewroman\pageref{LastPage}}页第\filltitle{1.5em}{\timesnewroman\thepage}页\\\vspace{5pt}% - \timesnewroman\HFUT@XueNians\titlefangsong~\timesnewroman\HFUT@XueNiane\titlefangsong 学年第\filltitle{2em}{\HFUT@XueQi}学期\hfill% - 课程代码\filltitle{5em}{\HFUT@KeChengDaiMa}\hfill% - 课程名称\filltitle{12em}{\HFUT@KeChengMingCheng}\hfill% - 学分\filltitle{2.5em}{\HFUT@XueFen}\hfill% - 课程性质: 必修\ifdefstring{\HFUT@KeChengXingZhi}{必修}{\boxyes}{\boxno}% - 选修\ifdefstring{\HFUT@KeChengXingZhi}{选修}{\boxyes}{\boxno}% - 限修\ifdefstring{\HFUT@KeChengXingZhi}{限修}{\boxyes}{\boxno}\hfill% - 考试形式: 开卷\ifdefstring{\HFUT@KaoShiXingShi}{开卷}{\boxyes}{\boxno}% - 闭卷\ifdefstring{\HFUT@KaoShiXingShi}{闭卷}{\boxyes}{\boxno}\\\vspace{2pt}% - 专业班级(教学班)\filltitle{11em}{\HFUT@ZhuanYeBanJi}\hfill% - 考试日期\filltitle{16em}{\HFUT@KaoShiRiQi}\hfill% - 命题教师\fillblank[5.5em][0.6cm]{\HFUT@MingTiJiaoShi}\hfill% - 系(所或教研室)主任审批签名% - \begin{tikzpicture}[overlay,xshift=3.25em,yshift=0.15cm]% - \node at (0,0) {\ifx\HFUT@XiZhuRenQianMing\@empty\else\includegraphics[height=0.9cm]{\HFUT@XiZhuRenQianMing}\fi};% - \end{tikzpicture}% - \filltitle{6.5em}{}\vspace{4pt}% +\newcommand{\hfutpage}{{\hfutFontTimes\thepage}} +\newcommand{\hfutlastpage}{{\hfutFontTimes\pageref*{LastPage}}} +\ifhfut@ShiJuan % 试卷页眉页脚 + \renewcommand\headrulewidth{0.5pt} + \renewcommand\footrulewidth{0.5pt} + \setCJKfamilyfont{hfutFontSimSun}[AutoFakeBold={3}]{SimSun} % 粗宋体 + \fancyhead[C]{\bfseries\large\hfutFontHead\hfutrule{6em} + \hfill\makebox[280mm][s]{\LARGE\hfutFontTitle~\hfut@BiaoTi~} + \hfill{\CJKfamily{hfutFontSimSun} 共\uline{\makebox[1.5em]{\hfutlastpage}}页第\uline{\makebox[1.5em]{\hfutpage}}页} + + \vspace{6pt}% + \hfut@XueNian{}学年第\uline{\hfill\hfut@XueQi\hfill}学期 + \hfill 课程代码\hfutul{\hfut@KeChengDaiMa} + \hfill 课程名称\hfutul{\hfut@KeChengMingCheng} + \hfill 学分\uline{\hfill\hfut@XueFen\hfill} + \hfill 课程性质: % + 必修\ifdefstring{\hfut@KeChengXingZhi}{必修}{\hfutboxyes}{\hfutboxno}% + 选修\ifdefstring{\hfut@KeChengXingZhi}{选修}{\hfutboxyes}{\hfutboxno}% + 限修\ifdefstring{\hfut@KeChengXingZhi}{限修}{\hfutboxyes}{\hfutboxno} + \hfill 考试形式: % + 开卷\ifdefstring{\hfut@KaoShiXingShi}{开卷}{\hfutboxyes}{\hfutboxno}% + 闭卷\ifdefstring{\hfut@KaoShiXingShi}{闭卷}{\hfutboxyes}{\hfutboxno} + + \vspace{6pt}% + 专业班级(教学班)\hfutul{\hfut@ZhuanYeBanJi} + \hfill 考试日期\hfutul{\hfut@KaoShiRiQi} + \hfill 命题教师\hfutul{\hfut@MingTiJiaoShi} + \hfill 系(所或教研室)主任审批签名\hfut@XiZhuRenQianMing% } \fancyfoot[C]{\small\vspace{0.5\baselineskip}命题教师注意事项: 1. 主考教师必须于考试一周前将“试卷A”、“试卷B”经教研室主任审批签字后送教务科印刷。\hspace{1em}% 2. 请命题教师用黑色水笔工整地书写题目或用A4纸横式打印贴在试卷版芯中。 } \fi -\ifHFUT@DaTiZhi%答题纸页眉页脚 - \fancyhead[C]{% - \bfseries\LARGE\xinsongti\scalebox{2.0}[1.0]{% - \ifdimcomp\ltitle>{0.35\linewidth}{\HFUT@BiaoTi}{\makebox[0.35\linewidth][s]{\HFUT@BiaoTi}}% - }\\\vspace{8pt}% - \large\timesnewroman\HFUT@XueNians\titlefangsong~\timesnewroman\HFUT@XueNiane\titlefangsong 学年第\filltitle{2em}{\HFUT@XueQi}学期\hfill% - 课程代码\filltitle{6.5em}{\HFUT@KeChengDaiMa}\hfill% - 课程名称\filltitle{13em}{\HFUT@KeChengMingCheng}\hfill% - 命题教师\filltitle{7em}{\HFUT@MingTiJiaoShi}\hfill% - 系主任审批% - \begin{tikzpicture}[overlay,xshift=3.5em,yshift=0.2cm]% - \node at (0,0) {\ifx\HFUT@XiZhuRenQianMing\@empty\else\includegraphics[height=0.9cm]{\HFUT@XiZhuRenQianMing}\fi};% - \end{tikzpicture}% - \filltitle{7em}{}\\\vspace{2pt}% - 教学班级\filltitle{10.5em}{}\hfill% - 学生姓名\fillblank[8em][0.6cm]{}\hfill% - 学号\filltitle{8em}{}\hfill% - 考试日期\filltitle{16em}{\HFUT@KaoShiRiQi}\hfill% - 成绩\filltitle{6.3em}{}\vspace{4pt}% - } - \fancyfoot[C]{\small\vspace{0.5\baselineskip} - 第 \timesnewroman\thepage 页~共 \timesnewroman\pageref{LastPage} 页 +\ifhfut@DaTiZhi % 答题纸页眉页脚 + \renewcommand\headrulewidth{0.5pt} + \renewcommand\footrulewidth{0.5pt} + \fancyhead[C]{\bfseries\large\hfutFontHead + \makebox[\linewidth][s]{\LARGE\hfutFontTitle~\hfut@BiaoTi~} + + \vspace{6pt}% + \hfut@XueNian{}学年第\uline{\hfill\hfut@XueQi\hfill}学期 + \hfill 课程代码\hfutul{\hfut@KeChengDaiMa} + \hfill 课程名称\hfutul{\hfut@KeChengMingCheng} + \hfill 命题教师\hfutul{\hfut@MingTiJiaoShi} + \hfill 系(所或教研室)主任审批签名\hfut@XiZhuRenQianMing% + + \vspace{6pt}% + 教学班级\hfutul{\hfutrule{10em}} + \hfill 学生姓名\hfutul{\hfutrule{10em}} + \hfill 学号\hfutul{\hfutrule{8em}} + \hfill 考试日期\hfutul{\hfut@KaoShiRiQi} + \hfill 成绩\hfutul{\hfutrule{6em}}% } + \fancyfoot[C]{\small\vspace{0.5\baselineskip}第~\hfutpage~页~~共~\hfutlastpage~页} \fi -\ifHFUT@CanKaoDaAn%参考答案页眉页脚 - \fancyhead[C]{% - \bfseries\LARGE\titlesongti\ifdimcomp\ltitle>{0.6\linewidth}{\HFUT@BiaoTi}{\makebox[0.6\linewidth][s]{\HFUT@BiaoTi}}\\\vspace{5pt}% - \large\timesnewroman\HFUT@XueNians\titlefangsong~\timesnewroman\HFUT@XueNiane\titlefangsong 学年第\filltitle{2em}{\HFUT@XueQi}学期\hfill% - 课程代码\filltitle{6.5em}{\HFUT@KeChengDaiMa}\hfill% - 课程名称\filltitle{13em}{\HFUT@KeChengMingCheng}\hfill% - 命题教师\filltitle{7em}{\HFUT@MingTiJiaoShi}\hfill% - 系主任审批% - \begin{tikzpicture}[overlay,xshift=3.5em,yshift=0.2cm]% - \node at (0,0) {\ifx\HFUT@XiZhuRenQianMing\@empty\else\includegraphics[height=0.9cm]{\HFUT@XiZhuRenQianMing}\fi};% - \end{tikzpicture}% - \filltitle{7em}{}\\\vspace{2pt}% - 教学班级\filltitle{10.5em}{}\hfill% - 学生姓名\fillblank[8em][0.6cm]{}\hfill% - 学号\filltitle{8em}{}\hfill% - 考试日期\filltitle{16em}{\HFUT@KaoShiRiQi}\hfill% - 成绩\filltitle{6.3em}{}\vspace{4pt}% - } - \fancyfoot[C]{\small\vspace{0.5\baselineskip} - 第 \timesnewroman\thepage 页~共 \timesnewroman\pageref{LastPage} 页 - } -\fi -\ifHFUT@Simple%简单模式页眉页脚 +\ifhfut@Simple % 简单模式页眉页脚 + \RequirePackage{hyperref} \renewcommand\headrulewidth{0pt} \renewcommand\footrulewidth{0pt} \renewcommand{\maketitle}{% - \begin{center} - \bfseries\LARGE\titlesongti% - \ifdimcomp\ltitle>{0.9\linewidth}{\HFUT@BiaoTi}{\makebox[0.9\linewidth][s]{\HFUT@BiaoTi}}\\% - \makebox[0.75\linewidth]{\large\timesnewroman\HFUT@XueNians\titlefangsong~\timesnewroman\HFUT@XueNiane\titlefangsong 学年% - 第{\HFUT@XueQi}学期\hfill\HFUT@KeChengMingCheng(\HFUT@KeChengDaiMa)} + \pdfbookmark{\hfut@BiaoTi}{hfutBiaoTi\thepage} + \begin{center}\bfseries + \makebox[\linewidth][s]{\LARGE\hfutFontTitle~\hfut@BiaoTi~} + + \vspace{6pt}% + \makebox[\linewidth]{\large\hfutFontHead~ + \hfill \hfut@XueNian{}学年第\hfut@XueQi{}学期 + \hspace{\stretch{3}} \hfut@KeChengMingCheng(\hfut@KeChengDaiMa) + \hfill~ + } \end{center} } - \fancyfoot[C]{\small\vspace{0.5\baselineskip} - 第 \timesnewroman\thepage 页~共 \timesnewroman\pageref{LastPage} 页 - } + \fancyfoot[C]{\small{}第~\hfutpage~页~~共~\hfutlastpage~页} \fi % 题号加粗 \renewcommand{\labelenumi}{{\bfseries \theenumi.}} % 题干 \newcommand\tigan[1]{\noindent{\large\textbf{#1}}} % 打分栏 -\RequirePackage{tikz} -\usetikzlibrary{overlay-beamer-styles} \newcommand\scorebox{% \vspace{0.5\baselineskip}\noindent% \begin{tikzpicture}[overlay,xshift=13.8cm,yshift=-1.6cm]% @@ -240,8 +204,7 @@ \newlength{\lquar} \newlength{\lhalf} \newlength{\lfull} -\RequirePackage[normalem]{ulem} -\NewDocumentCommand\fillblank{O{3.5cm} O{0.5cm} m}{% +\NewDocumentCommand\fillblank{O{35mm} O{5mm} m}{% \settodepth{\ltemp}{#3}% \uline{\makebox[#1]{\rule{0pt}{#2}\raisebox{\ltemp}{#3}}}% } @@ -298,9 +261,7 @@ \draw (0.9,0.5) node {#2} (0.9,1.5) node {\textbf{#1}};% \end{tikzpicture}% } -% 得分点命令 -% https://ask.latexstudio.net/ask/question/7557.html -\RequirePackage{zref-savepos} +% 得分点命令 https://ask.latexstudio.net/ask/question/7557.html \makeatletter \ExplSyntaxOn \zref@require@unique diff --git a/macros/latex/contrib/hfutexam/hfutexam.pdf b/macros/latex/contrib/hfutexam/hfutexam.pdf Binary files differindex a470ca1a02..69731d6fbc 100644 --- a/macros/latex/contrib/hfutexam/hfutexam.pdf +++ b/macros/latex/contrib/hfutexam/hfutexam.pdf diff --git a/macros/latex/contrib/hfutexam/hfutexam.tex b/macros/latex/contrib/hfutexam/hfutexam.tex index dc0f9769ab..0579704f5a 100644 --- a/macros/latex/contrib/hfutexam/hfutexam.tex +++ b/macros/latex/contrib/hfutexam/hfutexam.tex @@ -2,7 +2,7 @@ %% 示例所需的自定义命令 \newcommand{\diff}{\,\mathrm{d}} -\usetikzlibrary{arrows.meta, overlay-beamer-styles} +\usetikzlibrary{arrows.meta} \newfontfamily\couriernew{Courier New} \usepackage{enumitem} \usepackage{tcolorbox} @@ -12,11 +12,11 @@ \definecolor{lightgrey}{rgb}{0.9,0.9,0.9} \definecolor{frenchplum}{RGB}{190,20,83} \lstset{language=[LaTeX]TeX, - basicstyle=\couriernew, - texcsstyle=*\color{winered}, + basicstyle=\couriernew\color{blue}, + rulecolor=\color{black}, + texcsstyle=*\color{red}, mathescape, breaklines=true, - keywordstyle=\color{winered}, commentstyle=\color{green!70!black}, stringstyle=\color{green!50!blue}, frame=single, @@ -24,14 +24,14 @@ framerule=0.5pt, columns=flexible, backgroundcolor=\color{black!5}, - morekeywords={\diff, \maketitle, \titlesep, \BiaoTi, \XueNian, \XueQi, \KeChengDaiMa, \KeChengMingCheng, \XueFen, \KeChengXingZhi, \KaoShiXingShi, \ZhuanYeBanJi, \KaoShiRiQi, \MingTiJiaoShi, \XiZhuRenQianMing, \tigan, \scorebox, \score, \Score, \fillblank, \xx, \notice, \xuanzeti, \yihang, \erhang, \sihang, XeLaTeX}, - keywordstyle=\color{winered}, - morekeywords=[2]{hfutexam, shijuan, datizhi, cankaodaan, simple, nofangzheng, flalign, 5cm, enumerate, align}, - keywordstyle=[2]\color{blue}, + morekeywords={\diff, \maketitle, \titlesep, \BiaoTi, \XueNian, \XueQi, \KeChengDaiMa, \KeChengMingCheng, \XueFen, \KeChengXingZhi, \KaoShiXingShi, \ZhuanYeBanJi, \KaoShiRiQi, \MingTiJiaoShi, \XiZhuRenQianMing, \tigan, \scorebox, \score, \Score, \fillblank, \xx, \notice, \xuanzeti, \yihang, \erhang, \sihang, XeLaTeX, \hfutstretch}, + keywordstyle=\color{red}, + % morekeywords=[2]{hfutexam, shijuan, datizhi, cankaodaan, simple, nofangzheng, flalign, 5cm, enumerate, align}, + % keywordstyle=[2]\color{blue}, } \tcbset{ colback=white, - colframe=blue, + colframe=black, boxrule=0.5pt, arc=0pt, } @@ -56,7 +56,7 @@ \tigan{一、模板选项} \indent -本模板 (2022/12/07 v1.6) 旨在为将合肥工业大学试卷的 word 格式转为\LaTeX{}格式. +本模板 (2023/03/10 v1.7) 旨在为将合肥工业大学试卷的 word 格式转为\LaTeX{}格式. 使用时, 只需在文档开头写上 \begin{lstlisting} \documentclass[shijuan]{hfutexam} @@ -67,10 +67,10 @@ \indent 可使用的选项为: \lstinline|shijuan| (试卷), \lstinline|datizhi| (答题纸), \lstinline|cankaodaan| (参考答案) 和 \lstinline|simple| (简易模式). 如果留空则为默认值 \lstinline|shijuan| (试卷). \begin{enumerate} -\item 试卷/答题纸/参考答案三个选项下页面会设置为 A3 大小, 三种情形的页眉页脚显示的内容以及标题的文字间隔有所不同. +\item 试卷/答题纸/参考答案三个选项下页面会设置为 A3 大小的双栏模式, 相应的标题、页眉和页脚内容有所不同. \item 简易模式选项下页面会设置为 A4 大小, 页眉页脚也较为简单. 此时需要使用命令 \lstinline|\maketitle| 来生成标题. 一般用于保存(多张)试卷的内容,或者便于打印使用. -\item 标题默认使用方正字体, 因此请在使用前先安装字体: {\bfseries\titlesongti 方正小标宋}和{\bfseries\titlefangsong 方正仿宋}(右键选择为所有用户安装), 否则请使用选项 \lstinline|nofangzheng| (采用新宋体和仿宋代替). +\item 标题默认使用方正字体, 因此请在使用前先安装字体: {\bfseries\hfutFontTitle 方正小标宋}和{\bfseries\hfutFontHead 方正仿宋}(右键选择为所有用户安装), 否则请使用选项 \lstinline|nofangzheng| (采用新宋体和仿宋代替). \end{enumerate} \tigan{二、试卷信息} @@ -91,37 +91,38 @@ \ZhuanYeBanJi{少数民族预科班} % 专业班级, 一般不需要填写 \KaoShiRiQi{2022年6月18日8:00-10:00} % 考试日期 \MingTiJiaoShi{集体} % 命题教师 -\XiZhuRenQianMing{dengbing.png} % 系主任签名 +\XiZhuRenQianMing[5em]{dengbing.png} % 系主任签名的对应图片 \end{lstlisting} -其中系主任签名处需要填写相应的图片名, 若不设置或设置为空则不显示. +\indent 若不设置系主任签名或设置为空则不显示, 它的可选参数表示该图片的显示宽度, 默认为 \lstinline|5em|. 其它选项默认均为空, 可根据需要只填部分内容. -\newpage -\tigan{三、命令} +\tigan{三、解答题} \begin{enumerate} -\item \lstinline|\tigan{三、命令}| 用于生成题干, 字体相对较大, 且为黑体. 小题建议使用~{\color{blue}\lstinline|enumerate|} 环境来生成. +\item \lstinline|\hfutstretch{1.5}| 用于设置标题中\uline{带下划线文字两侧空格}与\uline{各分项之间空格}的宽度比, 默认为\lstinline|1.5|. +\item \lstinline|\tigan{三、解答题}| 用于生成题干, 为14pt黑体. 小题用~{\color{blue}\lstinline|enumerate|} 环境来生成. \item \hspace{-8mm}\scorebox\hspace{8mm}\lstinline|\scorebox| 用于生成打分框, 请放置在答题纸一行的开头使用. \vspace{-2mm} \item \lstinline|\notice| 用于生成答题纸提示信息, 请放置在答题纸的正文开始处. \item 答题纸中可能需要设置一定高度的空白, 使用命令 \lstinline|\hspace{5cm}| 之类的命令即可. 也可以使用 \lstinline|\newpage| 换到新的一页(或分栏). +\item 文档默认无缩进, 可在需要处使用命令 \lstinline|\indent| 生成. \end{enumerate} \tigan{填空题相关} \begin{enumerate}[resume] -\item \lstinline|\fillblank[长度][最低高度]{内容}| 用于生成填空题的空白, 内容可以为空. 其中长度默认值是~{\color{blue}{\lstinline|3.5cm|}}, 最低高度默认值是~{\color{blue}{\lstinline|0.5cm|}}. +\item \lstinline|\fillblank[长度][最低高度]{内容}| 用于生成填空题的空白, 内容可以为空. 其中长度默认值是~{\color{blue}{\lstinline|35mm|}}, 最低高度默认值是~{\color{blue}{\lstinline|5mm|}}. \end{enumerate} \textit{\color{blue}{填空题示例:}} \begin{lstlisting} -\textbf{请将你的答案对应填在横线上:}\\[0.5cm] +\textbf{请将你的答案对应填在横线上:}\\[5mm] \textbf{1.} \fillblank{}, \textbf{2.} \fillblank[5cm]{}, \textbf{3.} \fillblank{}. \end{lstlisting} \begin{tcolorbox} -\textbf{请将你的答案对应填在横线上:}\\[0.5cm] +\textbf{请将你的答案对应填在横线上:}\\[5mm] \textbf{1.} \fillblank{}, \textbf{2.} \fillblank[5cm]{}, \textbf{3.} \fillblank{}. @@ -130,8 +131,8 @@ \tigan{选择题相关} \begin{enumerate}[resume] \item \lstinline|\xx{选项}{选项}{选项}{选项}| 用于生成选择题的选项, 直接在选择题题干后使用即可. 该命令会自动根据选项长度设置行数. 只支持四个选项, 选项会自动带上 ABCD. -\item 如果想要手动改变每行显示的选项数, 可使用命令 \lstinline|\xx[每行显示的选项数]{选项}{选项}{选项}{选项}|, 每行只能显示 1, 2 或 4 个选项. -\item \lstinline|\xuanzeti{题号}{答案}| 用于生成答题纸选择题的答题区域, 或参考答案选择题的答案区域. +\item 该命令具有可选参数: \lstinline|\xx[每行显示的选项数]{选项}{选项}{选项}{选项}|, 每行只能显示 1, 2 或 4 个选项. +\item \lstinline|\xuanzeti{题号}{答案}| 用于生成答题纸或参考答案中选择题的答题区域. \end{enumerate} \textit{\color{blue}{选择题示例:}} @@ -175,7 +176,6 @@ \xuanzeti{1}{}\xuanzeti{2}{}\xuanzeti{3}{}\xuanzeti{4}{} \end{tcolorbox} -\newpage \tigan{得分点相关} \begin{enumerate}[resume] \item \lstinline|\score{数值}| 用于在参考答案一行结尾处生成得分点的虚线.\score2 @@ -186,8 +186,8 @@ \begin{lstlisting} \[\int e^x\diff x=e^x+C. \Score{(4分, 缺少常数得2分)}\] \begin{align*} -\int\sin x\diff x&=-\cos x+C, \Score{(4分, 缺少常数得2分)}\\ -\int_0^\pi(1+\sin x)\diff x&=\pi+2. \score5 + \int\sin x\diff x&=-\cos x+C, \Score{(4分, 缺少常数得2分)}\\ + \int_0^\pi(1+\sin x)\diff x&=\pi+2. \score5 \end{align*} \end{lstlisting} diff --git a/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.pdf b/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.pdf Binary files differindex 330e2c8ed7..5be4a7f7c1 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.pdf +++ b/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.pdf diff --git a/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.tex b/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.tex index e9ca966fc3..c4e8f069b9 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.tex +++ b/macros/latex/contrib/hfutexam/hfutexam_cankaodaan.tex @@ -1,4 +1,4 @@ -\documentclass[cankaodaan,blue]{hfutexam} +\documentclass[cankaodaan]{hfutexam} \usepackage{extarrows} \newcommand{\diff}{\,\mathrm{d}} @@ -14,7 +14,7 @@ \ZhuanYeBanJi{少数民族预科班} \KaoShiRiQi{2022年6月18日8:00-10:00} \MingTiJiaoShi{集体} -%\XiZhuRenQianMing{dengbing.png} +% \XiZhuRenQianMing{dengbing.png} \tigan{一、填空题(每小题3分,共18分)} diff --git a/macros/latex/contrib/hfutexam/hfutexam_datizhi.pdf b/macros/latex/contrib/hfutexam/hfutexam_datizhi.pdf Binary files differindex c1fdcc715a..28f58baf36 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_datizhi.pdf +++ b/macros/latex/contrib/hfutexam/hfutexam_datizhi.pdf diff --git a/macros/latex/contrib/hfutexam/hfutexam_datizhi.tex b/macros/latex/contrib/hfutexam/hfutexam_datizhi.tex index c0d3d1fa84..31e1b3576f 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_datizhi.tex +++ b/macros/latex/contrib/hfutexam/hfutexam_datizhi.tex @@ -2,24 +2,24 @@ \newcommand{\diff}{\,\mathrm{d}} \begin{document} -\BiaoTi{合肥工业大学考试专用答卷纸(A)} -\XueNian{2021}{2022} -\XueQi{二} -\KeChengDaiMa{034Y01} -\KeChengMingCheng{数学(下)} -\XueFen{5} +\BiaoTi{合肥工业大学考试专用答题纸(A)} +\XueQi{一} +\XueNian{2022}{2023} +\KeChengDaiMa{1400261B} +\KeChengMingCheng{复变函数与积分变换} +\XueFen{2.5} \KeChengXingZhi{必修} \KaoShiXingShi{闭卷} -\ZhuanYeBanJi{少数民族预科班} -\KaoShiRiQi{2022年6月18日8:00-10:00} +\ZhuanYeBanJi{} +\KaoShiRiQi{2022年11月26日19:00-21:00} \MingTiJiaoShi{集体} -%\XiZhuRenQianMing{dengbing.png} - +% 注意事项 \notice -%\scorebox 为打分框, 必须放在行首 -\scorebox\tigan{一、填空题(每小题3分,共18分)} +% \scorebox 为打分框, 必须放在行首 +\scorebox +\tigan{一、填空题(每小题3分,共18分)} \textbf{请将你的答案对应填在横线上:}\\[0.5cm] \textbf{1.} \fillblank{}, @@ -29,7 +29,8 @@ \textbf{5.} \fillblank{}, \textbf{6.} \fillblank{}. -\scorebox\tigan{二、选择题(每小题3分,共18分)} +\scorebox +\tigan{二、选择题(每小题3分,共18分)} \textbf{请将你所选择的字母 A, B, C, D 之一对应填在下列表格里:} @@ -43,29 +44,37 @@ \tigan{三、解答题(每小题8分,共64分)} -\scorebox\textbf{1. (8分)【解】} +\scorebox +\textbf{1. (8分)【解】} % \vspace 用于生成一定高度的空白, \newpage 直接换页 \vspace{3cm} -\scorebox\textbf{2. (8分)【解】} +\scorebox +\textbf{2. (8分)【解】} \newpage -\scorebox\textbf{3. (8分)【解】} +\scorebox +\textbf{3. (8分)【解】} \vspace{7cm} -\scorebox\textbf{4. (8分)【解】} +\scorebox +\textbf{4. (8分)【解】} \newpage -\scorebox\textbf{5. (8分)【解】} +\scorebox +\textbf{5. (8分)【解】} \vspace{7cm} -\scorebox\textbf{6. (8分)【证明】} +\scorebox +\textbf{6. (8分)【证明】} \newpage -\scorebox\textbf{7. (8分)【证明】} +\scorebox +\textbf{7. (8分)【证明】} \vspace{7cm} -\scorebox\textbf{8. (8分)【解】} +\scorebox +\textbf{8. (8分)【解】} \end{document} diff --git a/macros/latex/contrib/hfutexam/hfutexam_shijuan.pdf b/macros/latex/contrib/hfutexam/hfutexam_shijuan.pdf Binary files differindex b8e5045e71..35222d2cab 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_shijuan.pdf +++ b/macros/latex/contrib/hfutexam/hfutexam_shijuan.pdf diff --git a/macros/latex/contrib/hfutexam/hfutexam_shijuan.tex b/macros/latex/contrib/hfutexam/hfutexam_shijuan.tex index e4a5617329..9be69f2a92 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_shijuan.tex +++ b/macros/latex/contrib/hfutexam/hfutexam_shijuan.tex @@ -1,6 +1,6 @@ \documentclass{hfutexam} \newcommand{\diff}{\,\mathrm{d}} -\usetikzlibrary{arrows.meta, overlay-beamer-styles} +\usetikzlibrary{arrows.meta} \begin{document} \BiaoTi{合肥工业大学试卷(A)} @@ -12,10 +12,9 @@ \KeChengXingZhi{必修} \KaoShiXingShi{闭卷} \ZhuanYeBanJi{少数民族预科班} -\KaoShiRiQi{2022年6月18日8:00-10:00} +\KaoShiRiQi{2022年2月29日8:00-10:00} \MingTiJiaoShi{集体} -\XiZhuRenQianMing{} -% \XiZhuRenQianMing{dengbing.png} +% \XiZhuRenQianMing[4em]{dengbing.png} \tigan{一、填空题(每题3分,共18分)} \begin{enumerate} @@ -37,15 +36,15 @@ \item 设 $f(x)=\arctan\dfrac1{x(x-1)^2}$, 则 $x=0$ 是 $f(x)$ 的(~~~~). \xx{可去间断点}{跳跃间断点}{第二类间断点}{连续点} \item -\begin{tikzpicture}[overlay,xshift=13cm,yshift=-3.5cm] -\draw[-Stealth,thick](-3,0)--(3,0); -\draw[-Stealth,thick](0,-1)--(0,3); -\draw[very thick,smooth,domain=-55:55] plot ({\x/50-1.3}, {tan(\x)*tan(\x)}); -\draw[very thick,smooth,domain=0.15:2] plot ({\x}, {-ln(\x)}); -\draw - (-0.3,-0.3) node {$O$} - (2.8,-0.3) node {$x$} - (-0.3,2.8) node {$y$}; +\begin{tikzpicture}[overlay,xshift=130mm,yshift=-35mm] + \draw[-Stealth,thick](-3,0)--(3,0); + \draw[-Stealth,thick](0,-1)--(0,3); + \draw[very thick,smooth,domain=-55:55] plot ({\x/50-1.3}, {tan(\x)*tan(\x)}); + \draw[very thick,smooth,domain=0.15:2] plot ({\x}, {-ln(\x)}); + \draw + (-0.3,-0.3) node {$O$} + (2.8,-0.3) node {$x$} + (-0.3,2.8) node {$y$}; \end{tikzpicture} 设 $f(x)$ 是定义在 $(-\infty,+\infty)$ 上的连续函数, 且 $f'(x)$ 的图像如下图所示, 则 $f(x)$ 有(~~~~). % 手动设置为每行1个 diff --git a/macros/latex/contrib/hfutexam/hfutexam_simple.pdf b/macros/latex/contrib/hfutexam/hfutexam_simple.pdf Binary files differindex b7008d98fe..157e0a4c4f 100644 --- a/macros/latex/contrib/hfutexam/hfutexam_simple.pdf +++ b/macros/latex/contrib/hfutexam/hfutexam_simple.pdf diff --git a/macros/latex/contrib/photobook/photobook.cls b/macros/latex/contrib/photobook/photobook.cls index c5e4f8d925..8f9da6cf24 100644 --- a/macros/latex/contrib/photobook/photobook.cls +++ b/macros/latex/contrib/photobook/photobook.cls @@ -33,6 +33,8 @@ % to edit it directly, edit the source instead. % % +% XXC FEATURE image spread: add ability to push image sides outward to +% account for gutter.,, % XXX revise \clearcaption / \captionclearpage... % XXX unify API -- see CellContent env... % XXX make this loadable both as a class and as a package... @@ -65,14 +67,17 @@ % - \CopyrightNotice % - ... % - info +% XXX DOC add notes about external libs section: +% - textpos +% cell/cell* depend on absolute mode being set globally % % %---------------------------------------------------------------------- %%% NOTE: \def\<module-name>@[A-Z]+ macros will be visible to both the %%% code and the generated docs... -\edef\photobook@FILEVERSION{v0.1.9} -\edef\photobook@FILEDATE{2023-03-01} +\edef\photobook@FILEVERSION{v0.1.10} +\edef\photobook@FILEDATE{2023-03-11} %% \documentclass{ltxdoc} @@ -705,6 +710,8 @@ \newlength\coverflap \setlength\coverflap{\photobook@coverflap} +\newlength\photobook@coverflap@active + %% \DescribeMacro{\jacketwrap=<len>} %% \DescribeMacro{\jacketflap=<len>} %% \DescribeMacro{\jacketflapfront=<len>} @@ -721,6 +728,11 @@ \newlength\jacketflapback \setlength\jacketflapback{\photobook@jacketflapback} +\newlength\photobook@jacketwrap@active +\newlength\photobook@jacketflap@active +\newlength\photobook@jacketflapfront@active +\newlength\photobook@jacketflapback@active + %% \DescribeMacro{\blockwidth=<len>} %% \DescribeMacro{\blockheight=<len>} % @@ -987,17 +999,28 @@ \def\pdfpagelayout{SinglePage}\fi \else \def\pdfpagelayout{\photobook@pdfpagelayout}\fi - % items to ignore in different layouts... - \ifcoverlayout\else - \setlength\coverflap{0pt}\fi - \ifjacketlayout\else - \setlength\jacketwrap{0pt} - \setlength\jacketflap{0pt}\fi - % flaps... - \ifdim\jacketflapfront=0pt - \setlength\jacketflapfront{\jacketflap}\fi - \ifdim\jacketflapback=0pt - \setlength\jacketflapback{\jacketflap}\fi + % keep user settings but respect the current layout... + \ifcoverlayout + \setlength\photobook@coverflap@active{\coverflap} + \else + \setlength\photobook@coverflap@active{0pt}\fi + \ifjacketlayout + \setlength\photobook@jacketwrap@active{\jacketwrap} + \setlength\photobook@jacketflap@active{\jacketflap} + % flaps... + \ifdim\jacketflapfront=0pt + \setlength\photobook@jacketflapfront@active{\photobook@jacketflap@active} + \else + \setlength\photobook@jacketflapfront@active{\jacketflapfront}\fi + \ifdim\jacketflapback=0pt + \setlength\photobook@jacketflapback@active{\photobook@jacketflap@active} + \else + \setlength\photobook@jacketflapback@active{\jacketflapback}\fi + \else + \setlength\photobook@jacketwrap@active{0pt} + \setlength\photobook@jacketflap@active{0pt} + \setlength\photobook@jacketflapfront@active{0pt} + \setlength\photobook@jacketflapback@active{0pt}\fi % block size... \ifdim\blockwidth=0pt % layout: block... @@ -1041,7 +1064,7 @@ \pagestyle{empty}% \setsepchar{,}% \readlist*\pagefoldpanels{% - \the\jacketflapback, + \the\photobook@jacketflapback@active, \the\jacketwrap, \the\dimexpr \coverboardgrow @@ -1053,7 +1076,7 @@ \coverboardgrow + \pageblockwidth \relax, \the\jacketwrap, - \the\jacketflapfront}% + \the\photobook@jacketflapfront@active}% \photobook@setpagefold{out} \setlength\blockwidth{ \dimexpr @@ -1062,8 +1085,8 @@ + \spinewidth + 2\spinefold + 2\jacketwrap - + \jacketflapfront - + \jacketflapback \relax}\fi + + \photobook@jacketflapfront@active + + \photobook@jacketflapback@active \relax}\fi % layout: endpaper... \ifendpaperlayout \pagestyle{empty}% @@ -1386,6 +1409,7 @@ %% packed in. %% \newenvironment{page}{% + % XXX do we need \null here??? \null% \ignorespaces% }{% @@ -1695,6 +1719,14 @@ % %% >> \begin{cell*}{<left>, <top>}{<width>}{<height>} ... \end{cell*} %% +%% |cell| and |cell*| are absolutely positioned either relative to +%% the current page or to the closest savecell. +%% +% XXX should this have an explicit absolute/relative option??? +% XXX handle textpos's absolute option internally (+arg) ??? +% - save external state +% - set internal state +% - reset bac to saved % XXX SYNTAX: place the second arg in braces... % \begin{cell*}(<left>, <top>){<width>}{<height>} %\newenvironment{cell*}[3]{% @@ -1772,6 +1804,11 @@ %% |\gsavecell{..}| is the same as |\savecell{..}| but creates a global %% cell. %% +%% Note that both |\gsavecell{..}| and |\savecell{..}| make the nested +%% |cell| and |cell*| position relative to the cell and not the page. +%% This is done by setting |\TPoptions{absolute=false}| for the cell +%% content which will also affect |textpos|'s macros. +%% % XXX can/should we make this an env??? % XXX should this be split into \newsavecell{..} and \scell{..} ??? % XXX can we use root cells inside this??? @@ -3793,15 +3830,15 @@ \newenvironment{frontcover}{% \begin{cell*}{ \bleed - + \jacketflapback - + \coverflap - + \jacketwrap + + \photobook@jacketflapback@active + + \photobook@coverflap@active + + \photobook@jacketwrap@active + \coverboardgrow + \pageblockwidth + 2\spinefold + \spinewidth, \bleed - + \coverflap }% + + \photobook@coverflap@active }% { \pageblockwidth + \coverboardgrow }% { \pageblockheight + 2\coverboardgrow }% }{% @@ -3810,11 +3847,11 @@ \newenvironment{backcover}{% \begin{cell*}{ \bleed - + \jacketflapback - + \coverflap - + \jacketwrap, + + \photobook@jacketflapback@active + + \photobook@coverflap@active + + \photobook@jacketwrap@active, \bleed - + \coverflap }% + + \photobook@coverflap@active }% { \pageblockwidth + \coverboardgrow }% { \pageblockheight + 2\coverboardgrow }% }{% @@ -3826,14 +3863,14 @@ \newenvironment{spine}{% \begin{cell*}{ \bleed - + \jacketflapback - + \coverflap - + \jacketwrap + + \photobook@jacketflapback@active + + \photobook@coverflap@active + + \photobook@jacketwrap@active + \coverboardgrow + \pageblockwidth + \spinefold, \bleed - + \coverflap }% + + \photobook@coverflap@active }% { \spinewidth }% { \pageblockheight + 2\coverboardgrow }% }{% @@ -3854,15 +3891,15 @@ \newenvironment{frontflap}{% \begin{cell*}{ \bleed - + \jacketflapback - + 2\jacketwrap + + \photobook@jacketflapback@active + + 2\photobook@jacketwrap@active + 2\coverboardgrow + 2\pageblockwidth + 2\spinefold + \spinewidth, \bleed - + \coverflap }% - { \jacketflapfront }% + + \photobook@coverflap@active }% + { \photobook@jacketflapfront@active }% { \pageblockheight + 2\coverboardgrow }% }{% \end{cell*}} @@ -3871,8 +3908,8 @@ \begin{cell*}{ \bleed, \bleed - + \coverflap }% - { \jacketflapback }% + + \photobook@coverflap@active }% + { \photobook@jacketflapback@active }% { \pageblockheight + 2\coverboardgrow }% }{% \end{cell*}} diff --git a/macros/latex/contrib/photobook/photobook.pdf b/macros/latex/contrib/photobook/photobook.pdf Binary files differindex c10cb7eba2..64778bbbf3 100644 --- a/macros/latex/contrib/photobook/photobook.pdf +++ b/macros/latex/contrib/photobook/photobook.pdf diff --git a/macros/latex/contrib/photobook/scripts/README.md b/macros/latex/contrib/photobook/scripts/README.md new file mode 100644 index 0000000000..5970cfbb72 --- /dev/null +++ b/macros/latex/contrib/photobook/scripts/README.md @@ -0,0 +1,423 @@ + +Support scripts +=============== + +<!-- TOC depthfrom:2 --> + +- [make-spreads.sh](#make-imagessh) + - [The process](#the-process) + - [Automatic template inferenceing](#automatic-template-inferenceing) + - [Manual template selection](#manual-template-selection) + - [Template tweaking](#template-tweaking) + - [Manual spread layouts](#manual-spread-layouts) + - [Templates](#templates) + - [Image captions](#image-captions) + - [Environment variables and configuration](#environment-variables-and-configuration) +- [cls2tex.sh](#cls2texsh) + +<!-- /TOC --> + + +--- + +`make-spreads.sh` +---------------- + +Generate LaTeX block of pages from a directory tree. + +This was initially intended as a means to convert the exported directory +tree from an image viewer where image/text sequencing was done, but it +can also be used standalone. + +Goals: +- Decouple layout, sequencing, images, processing and different texts + to enable different people to work on them independently and in + parallel, +- Simplify editing the page/spread sequence, +- Automate the build process. + + +A typical project tree: +``` +book/ +├── templates/ . . . . . . . . . . . . Global templates. +│ ├── imagepage.tex . . . . . . . . . Single page image template, +│ ├── textpage.tex . . . . . . . . . Single page text template, +│ │ These are used to build spreads +│ │ when no explicit template matches. +│ ├── blank-image.tex +│ ├── image-blank.tex +│ ├── image-image.tex +│ ├── fullbleed.tex +│ └── ... +├── spreads/ . . . . . . . . . . . . . . Main block layout. +│ ├── 00/ . . . . . . . . . . . . . . A basic spread. +│ │ ├── tweaks.tex The spread template is built +│ │ └── 0-DSC02432.jpg automatically with tweaks.tex +│ │ prepended. +│ ├── 01/ +│ │ ├── 0-DSC02439.jpg +│ │ └── 1-intro.txt +│ ├── 02/ +│ │ ├── fullbleed.tpl . . . . . . . Explicitly use a global template. +│ │ └── 1-DSC02511.jpg +│ ├── 03/ +│ │ ├── 0-DSC02509-0.jpg +│ │ └── 1-DSC02506-0.jpg +│ └── ... +├── captions/ . . . . . . . . . . . . . Image captions. +│ ├── DSC02432.txt +│ ├── DSC02439.txt +│ ├── DSC02511.txt +│ └── ... +├── setup.tex . . . . . . . . . . . . . Book block setup. +│ This is included by all top level +│ .tex files like block.tex, +│ cover.tex, ...etc. +├── block.tex . . . . . . . . . . . . . Block skeletal layout. +│ This usually includes the titles, +│ technical pages and sources the +│ ./block-pages.tex. +├── block-pages.tex . . . . . . . . . . The generated block content. +├── cover.tex . . . . . . . . . . . . . Cover layout. +├── jacket.tex . . . . . . . . . . . . Dust jacket layout. +└── ... +``` + +<!-- XXX +For a live example see: ../examples/book --> + +Generate the block: +```shell +$ make-spreads.sh ./pages > block-pages.tex +``` + +Note that `make-spreads.sh` does not force a specific layout outside of +the `pages` directory, all paths are configurable. The way the root +files are structured in this example is just one way to organize a +book's source code with minimal code duplication. + + +For runtime help see: +```shell +$ make-spreads.sh --help +``` + + +### The process + +<!-- XXX spreads vs. pages --> + +The system is designed to minimize the effort in laying out pages, so +when designing a book the focus should be on global templates and on +helping `make-spreads.sh` build them rather than trying to layout each +spread individually. + +There are several ways to arrive at a book layout starting from the +concept, through the edit, sequencing, structuring and the graphic +design, we here will focus on the stage of the process where a body of +work is starting to look like a book. + +When starting work on a layout it is good to at least have a basic +understanding of the book's: +- structure and how it may change, +- core templates, +- exceptions from the above. + +In most cases all of the above will change in one way or another during +the project's lifespan, and the main goal of this stage is to make this +change as simple as possible -- it's all about providing the freedom to +make changes instead of growing work invested and thus making change +more and more expensive. + +The first question is what is the _structure_ of the book we are making? +Will it have chapters? How many? Text? how much, how should it be +structured? How are we going to deal with the title? How are we going +to present the images, full bleed, no bleeds, small, big, one per page +or multiple images, ...etc.? At this stage this is about the presentation +the flow of the work and not about the actual design. How many typical +spreads (i.e. spread templates) should it have? A good number should be +small-ish, for example 3-4 spread templates is a good number, if you +count 10+ then you might be overcomplicating tings, but note, there are +no rules, a book where each spread is individually and manually layed out +may work as well as a book with just a single template spread, but in +general for a photo book the focus is on the project and the layout +should work with it without overwhelming it. + +Have answers, good, now it's time to build those mock layouts and make +them into basic templates. + +It would be simplest to start work with the basic templates provided by +`photobook` (see: ../examples/spread templates/templates/) and rework +them when or if needed. + +The templates are split into two levels: +- Page templates + These are typical pages that makeup a spread, usually an + image page (`imagepage.tex`), a text page (`textpage.tex`), and an + optional empty page (`emptypage.tex`), `make-spreads.sh` can combine + them to build spreads automatically. +- Spread templates + These typeset a spread and can be either automatically inferred from + the structure or manually selected. + + +#### Automatic template inferencing + +If no explicit template is defined (see next section) `make-spreads.sh` +will try and infer a template based on the number of images in the +spread directory, if that is not possible the it will build a spread +from page templates based on the sequence of first two image/text files. + +For example with the default settings and the templates defined above: + +``` +├── 01/ +│ ├── 0-DSC02439.jpg +│ └── 1-intro.txt +``` + +Will use `imagepage.tex` and `textpage.tex` templates to build the spread, +while the following: + +``` +├── 03/ +│ ├── 0-DSC02509-0.jpg +│ └── 1-DSC02506-0.jpg +``` + +Will use `image-image.tex`. + +Note that if a spread template is not found `make-spreads.sh` fallback to +page templates, e.g. if we delete `image-image.tex` then `imagepage.tex` +will be used for both pages of the spread instead. + +If only one image/text file is provided then `make-spreads.sh` will set it +on the right page of the spread using the appropriate page template and +leave the left page blank. + +<!-- XXX do we need a `blankpage.tex` template??? --> + + +#### Manual template selection + +A template can be selected manually by providing a file in the form: + +```bnf +<template-name>.tpl +``` + +The content of this file is ignored and `templates/<template-name>.tex` +will be used for that spread. + +Example: +``` +├── 02/ +│ ├── fullbleed.tpl +│ └── 1-DSC02511.jpg +``` + +Here `templates/fullbleed.tex` will be used. + + +#### Template tweaking + +If the file `tweaks.tex` is present in the spread directory its contents +are included in the built block at the start of that spread. + +This can be useful to _tweak_ the spread, for example to set page/font +color, tweak image positioning in some of the `photobook`'s template +spread macros (see: tweaking section in photobook.pdf). + +Example: +``` +├── 00/ +│ ├── tweaks.tex +│ └── 0-DSC02432.jpg +``` + +Note that this can both apply to a single spread as well as a set of +spreads, of example page or text colors are not reset automatically +and will affect all subsequent spreads until manually reset (in a +different spread's `tweaks.tex` file), while `photobook`'s tweaks apply +only to a single page. + + +#### Manual spread layouts + +If `layout.tex` is present it will be included as the page layout/template. + +Any paths in the `layout.tex` should be relative to the location the +built block .tex file will be located, usually to the project root. + + +### Templates + +A template is a LaTeX file with zero or more special fields defined. + +Field types: +- `${IMAGE}` / `${IMAGE<number>}` + Filled with image path. +- `${CAPTION}` / `${CAPTION<number>}` + Filled with caption file content +- `${TEXT}` / `${TEXT<number>}` + Filled with text file content + +Each field can be used more than once, the field value will be copied to +each instance. + +Multiple fields of the same type can be provided and each will be filled +with corresponding data in order, e.g. the third image filed will get +the third image path. Note that we are talking of field order and not +field number, this removes the need to constantly keep the field/file +numbers matched when adding and removing files/fields, all one needs to +do is keep the order the same. + +If a field is not filled it will be empty in the resulting `.tex`. + +Example template `templates/fullbleed.tex`: +``` +\ImageSpreadFill{${CAPTION}}{${IMAGE0}} +``` + + +### Image captions + +In general image captions are decoupled from the main layout to enable +writers and editors to work on them externally. + +```bnf +captions/ +├── <image-name>.txt +└── ... +``` + +The captions folder name/location is controlled by the `$CAPTION_DIR` +environment variable. + + +Inline captions are also supported: +```bnf +pages/ +├── <spread>/ +│ ├── ... +│ ├── 00-<image-name>.<ext> +│ ├── 00-<image-name>.txt . . . . . . Local image caption +│ └── ... +└── ... +``` +An inline caption must have the same filename as the corresponding image +but with a .txt extension. + + +### Environment variables and configuration + +All the configuration options can be given in a configuration file as +well as environment variables. + +<!-- XXX this is not true at the moment, not sure if this is a bug or a feature... +Environment variables take precedence over the configuration file. --> + +The default `make-images.cfg` would look something like: +```shell +# if non-empty make-spreads.sh will add image paths to pdf notes... +ANOTATE_IMAGE_PATHS= + +# file extensions to treat as text (separated with "|") +TEXT_FORMATS=txt + +# file extensions to treat as images (separated with "|") +IMAGE_FORMATS=jpeg|jpg|png|pdf|svg|eps + +# default directory spread definitions are located in... +SPREADS_DIR=spreads/ + +# if non-empty link link images to matching ones from this directory... +IMAGE_HIRES_DIR= + +# directory where external captions are stored... +CAPTION_DIR=captions/ + +# root template directory... +TEMPLATE_DIR=templates/ + +# empty page template... +EMPTY_PAGE=emptypage + +# text page template... +TEXT_PAGE=textpage + +# image page template... +IMAGE_PAGE=imagepage + +# spread templates... +IMAGE_SPREAD=( + # + # +------- number of found images + # / +-- template name + # / / + [0]=text-spread + [2]=image-image +) +``` + + +--- + +`cls2tex.sh` +------------ + +Extract the documentation from photobook.cls which is used to build the +photobook.pdf reference manual. + +```shell +$ cls2tex.sh --help +``` + +The `--help` says it all: +``` +Generate docs from latex package/class + +Usage: + cls2tex.sh [OPTIONS] [[INPUT] OUTPUT] + +Options: + -h | --help Show this message and exit + -p | --prefix PREFIX + Set the doc comment PREFIX (default: "%") + -s | --strip Strip docs out + -n | --no-msg Don't add the "generated with" message to output + +This will: + - read the INPUT + - keep lines starting with \def\<module-name>@[A-Z]\+ + - keep lines starting with '%%' + - %%%%% Text -> \subsection(Text) + - %%%% Text -> \section(Text) + - %% >> code -> \begin{verbatim}code\end{verbatim} + - write the result to OUTPUT + +If no OUTPUT is given cls2tex.sh will write to stdout. If no INPUT +is given cls2tex.sh will read stdin. + +PREFIX can replace the second "%" in the above patterns to make it +possible to integrate multiple layers of documentation in one file +and to integrate them in various ways, for example, in the photobook +document class documentation "M" prefix is used to indicate +meta-command docs, this enables us to document them in the relevant +location (i.e. at the implementation) in source but move the docs to +a unified location in docs, effectively decoupling the source and doc +structure when needed. + +Strip mode is the reverse of of the default, it will strip out docs +and empty lines, keeping only the actual code and code comments. + +NOTE: stripping will not remove non-doc comments. +NOTE: the idea of keeping latex docs in a latex file is far simpler + than all the stuff crammed into .dtx, at least for my needs: + - keep the code readable + - keep the docs readable + in both the repo and in installed form, so .dtx is not used. +``` + + diff --git a/macros/latex/contrib/photobook/scripts/cls2tex.sh b/macros/latex/contrib/photobook/scripts/cls2tex.sh index 8ec15ebf45..d7e6c1013e 100755 --- a/macros/latex/contrib/photobook/scripts/cls2tex.sh +++ b/macros/latex/contrib/photobook/scripts/cls2tex.sh @@ -31,7 +31,7 @@ printhelp(){ echo " - %% >> code -> \\begin{verbatim}code\\end{verbatim}" echo " - write the result to OUTPUT" echo - echo "If no OUTPUT is given $SCRIPT_NAME will read stdout. If no INPUT" + echo "If no OUTPUT is given $SCRIPT_NAME will write to stdout. If no INPUT" echo "is given $SCRIPT_NAME will read stdin." echo echo "PREFIX can replace the second \"%\" in the above patterns to make it" @@ -132,11 +132,12 @@ if [ -z $STRIP_DOC ] ; then > "$OUTPUT" cat "$INPUT" \ | egrep '(^%'$PREFIX'|^\\edef\\'$MODULE'@[A-Z][A-Z]+)' \ - | sed 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \ - | sed 's/%'$PREFIX'%%%% \(.*\)/%'$PREFIX'\\subsubsection{\1}\\label{subsubsec:\1}/' \ - | sed 's/%'$PREFIX'%%% \(.*\)/%'$PREFIX'\\subsection{\1}\\label{subsec:\1}/' \ - | sed 's/%'$PREFIX'%% \(.*\)/%'$PREFIX'\\section{\1}\\label{sec:\1}/' \ - | sed 's/%'$PREFIX'\s\+>>\s\+\(.*\)/%'$PREFIX'\\begin{verbatim} \1 \\end{verbatim}/' \ + | sed \ + -e 's/^\(\\edef\\\)'$MODULE'@/%'$PREFIX'\1/' \ + -e 's/%'$PREFIX'%%%% \(.*\)/%'$PREFIX'\\subsubsection{\1}\\label{subsubsec:\1}/' \ + -e 's/%'$PREFIX'%%% \(.*\)/%'$PREFIX'\\subsection{\1}\\label{subsec:\1}/' \ + -e 's/%'$PREFIX'%% \(.*\)/%'$PREFIX'\\section{\1}\\label{sec:\1}/' \ + -e 's/%'$PREFIX'\s\+>>\s\+\(.*\)/%'$PREFIX'\\begin{verbatim} \1 \\end{verbatim}/' \ | cut -c 3- - \ >> "$OUTPUT" @@ -153,4 +154,4 @@ fi #---------------------------------------------------------------------- -# vim:set ts=4 sw=4 nowrap : +# vim:set ts=4 sw=4 nowrap : diff --git a/macros/latex/contrib/photobook/scripts/make-images.sh b/macros/latex/contrib/photobook/scripts/make-images.sh deleted file mode 100644 index bfec27d978..0000000000 --- a/macros/latex/contrib/photobook/scripts/make-images.sh +++ /dev/null @@ -1,450 +0,0 @@ -#!/bin/bash -shopt -s nullglob extglob - -#---------------------------------------------------------------------- -# -# Template structure: -# templates/ -# imagepage.tex -# textpage.tex -# ... -# $IMAGE_DIR/ -# $spread/ -# tweaks.tex -# template tweaks. -# loaded before the templates are handled. -# layout.tex -# manual layout of spread. -# if given rest of directory contents are -# ignored. -# fields: -# ${IMAGE0} -# ${CAPTION0} -# ${IMAGE1} -# ${CAPTION1} -# NOTE: if images are included, hi-res source -# substitution is not done here. -# <spread-template-name>.tpl -# indicates the spread template to use. -# if given the rest of the .tex files in -# directory are ignored. -# resolves to: -# templates/<spread-template-name>.tex -# fields: -# ${IMAGE0} -# ${CAPTION0} -# ${IMAGE1} -# ${CAPTION1} -# imagepage.tex -# image page template. -# fields: -# ${IMAGE} -# ${CAPTION} -# textpage.tex -# text page template. -# fields: -# ${TEXT} -# <spread-template-name>-imagepage.tpl -# <spread-template-name>-textpage.tpl -# indicates the image/text page template to use. -# ignored if explicit templates are given. -# image fields: -# ${IMAGE} -# ${CAPTION} -# text fields: -# ${TEXT} -# 00-<image>.png -# image. -# if $IMAGE_HIRES_DIR is set then this will -# resolve to: -# $IMAGE_HIRES_DIR/<image> -# XXX hi-res substitution currently disabled. -# 01-<text>.txt -# text. -# ... -# ... -# -# -# -# Env variables: -# IMAGE_HIRES_DIR=<path> -# sets the path to which the hi-res images are resolved. -# -# -# -# -# XXX TODO: -# - revise printed comments... -# - add real arg handling... -# - add abbility to apply template to a specific page in spread... -# ...something like: -# <template-name>-left.tpl -# <template-name>-right.tpl -# - add multiple images/captions... -# -# -# -#---------------------------------------------------------------------- - -# defaults... - -CFG_FILE=`basename $0`.cfg - -TEMPLATE_PATH=templates/ - -IMAGE_DIR=pages/ - -#IMAGE_HIRES_DIR= - - -# Default timplates -#SINGLE_IMAGE=blank-image -SINGLE_IMAGE=imagebleedleft -DOUBLE_IMAGE=image-image - - -# load config... -[ -e $CFG_FILE ] && source $CFG_FILE - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -printhelp(){ - echo "Usage: `basename $0` [ARGUMENTS] [PATH]" - echo " `basename $0` [ARGUMENTS] PATH FROM [COUNT]" - echo - echo "Generate LaTeX layout from directory structure." - echo - echo "Arguments:" - echo " -h --help - print this help and exit." - echo " --templates=PATH" - echo " - path to search for templates (default: $TEMPLATE_PATH)." - echo " --single-image-tpl=NAME" - echo " - single image default template (default: $SINGLE_IMAGE)." - echo " --double-image-tpl=NAME" - echo " - double image default template (default: $DOUBLE_IMAGE)." - echo - echo "Parameters:" - echo " PATH - path to root pages directory (default: $IMAGE_DIR)" - echo " FROM - spread to start from (default: 0)" - echo " COUNT - number of spreads to generate (default: 1)" - echo - echo "Environment:" - echo " \$IMAGE_HIRES_DIR " - echo " - source directory for replacement hi-res images." - echo " \$ANOTATE_IMAGE_PATHS " - echo " - if true add image paths in anotations." - echo - echo "Configuration defaults can be stored in a config file: $CFG_FILE" - echo - echo "NOTE: COUNT is relevant iff FROM is given, otherwise all available " - echo " spreads are generated." - echo - echo "Examples:" - echo " $ `basename $0` ./pages > pages.tex" - echo " - generate a layout fron the contents of ./pages" - echo - echo " $ IMAGE_HIRES_DIR=images/hi-res `basename $0` ./pages" - echo " - generate a layout fron the contents of ./pages and " - echo " replaceing local images with images in ./images/hi-res" - echo -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# handle arguments... - -while true ; do - case $1 in - -h|--help) - printhelp - exit - ;; - - --templates) - TEMPLATE_PATH=$2 - shift - shift - ;; - --single-image-tpl) - SINGLE_IMAGE=$2 - shift - shift - ;; - --double-image-tpl) - DOUBLE_IMAGE=$2 - shift - shift - ;; - - # handle unknown options... - -*|--*) - echo "Error: unknown option \"$1\"" - exit - ;; - - *) - break - ;; - esac -done - - -if [ -z $1 ] ; then - IMAGE_DIR=pages/ -else - IMAGE_DIR=$1/ -fi - - -# calculate spread index range... -# XXX add support for negative indexing... -FROM=$2 -COUNT=$( [ -z $3 ] && echo 1 || echo $3 ) -STOP=$(( FROM + COUNT )) - - - -#---------------------------------------------------------------------- - -# XXX should we report images w/o captions??? -getCaption(){ - local C=`basename "${1%.*}"` - #C="${C/[0-9]-}" - C="captions/${C}.txt" - - if [ -e "${C}" ] ; then - C=`cat "${C}" | sed 's/\\\/\\\\\\\/g'` - else - C="" - fi - - echo ${C[*]} -} - -getTemplate(){ - local SPREAD=$1 - local TYPE=$2 - local TEMPLATE=($SPREAD/*-$TYPE.tex) - if [ -z $TEMPLATE ] ; then - TEMPLATE=($SPREAD/*-$TYPE.tpl) - if ! [ -z $TEMPLATE ] ; then - TEMPLATE=${TEMPLATE/$SPREAD\//} - TEMPLATE=${TEMPLATE/[0-9]-/} - TEMPLATE="$TEMPLATE_PATH/${TEMPLATE[0]%-${TYPE}.*}.tex" - fi - fi - if [ -z $TEMPLATE ] ; then - TEMPLATE="$TEMPLATE_PATH/${TYPE}.tex" - fi - echo $TEMPLATE -} - -anotatePath(){ - if [ -z "$1" ] || [ -z "$ANOTATE_IMAGE_PATHS" ] ; then - return - fi - path=$(basename ${1%.*}) - # NOTE: did not figure out how to make a verbatim comment in latex - # so here we are, doing it in shell... - path=${path//_/\\_} - #echo "\\pdfmargincomment{Image: $path}%" - echo "\\pdfcommentcell{Image: $path}%" -} - - -#---------------------------------------------------------------------- - - -echo %---------------------------------------------------------------------- -echo % -echo % WARNING: This file is auto-generated by make-images.sh and will be -echo "% overwritten on next run..." -echo % -echo "% Image source (preview): \"$IMAGE_DIR\"" -echo "% Image source (hi-res): \"$IMAGE_HIRES_DIR\"" -echo % -echo %---------------------------------------------------------------------- -echo % -#echo % set image source directory... -#echo "\\graphicspath{{${IMAGE_DIR}}}" -#echo % -#echo %---------------------------------------------------------------------- -#echo % -# -#cd ${IMAGE_DIR} - -l=$(ls "$IMAGE_DIR/" | wc -l) -c=0 - -for spread in "${IMAGE_DIR}"/* ; do - # skip non-spreads... - if ! [ -d "$spread" ] ; then - continue - fi - - c=$(( c + 1 )) - - # if $FROM is given print only stuff in range... - [ -z $FROM ] \ - || if (( $(( c - 1 )) < $FROM )) || (( $c > $STOP )) ; then - continue - fi - - # if we are building only a specific spread... - ##if ! [ -z $SPREAD ] && [[ "$spread" != "$IMAGE_DIR/$SPREAD" ]]; then - ## continue - ##fi - - if ! [ -z $SKIP_FIRST ] ; then - echo % - echo % - echo % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fi - SKIP_FIRST=1 - # skip temporarily disabled... - if [ -z ${spread/-*/} ] ; then - echo "% spread: ${spread/-/}: skipped..." | tee >(cat >&2) - echo % - continue - else - printf "Spread ($c/$l): ${spread/-/} \r" >&2 - echo "% spread: ${spread/-/}" - fi - - - # auto layout / templates... - # NOTE: to use a specific template just `touch <template-name>.tpl` - # in the spread directory... - - # layout tweaks... - tweaks=($spread/*tweak.tex) - if ! [ -z ${tweaks} ] ; then - echo "% tweaks: ${tweaks[0]}" - cat ${tweaks[0]} - fi - - - # NOTE: we also get *.txt files here... - items=($spread/*.!(tex|tpl|bak)) - - # get hi-res image paths... - if ! [ -z $IMAGE_HIRES_DIR ] ; then - C=0 - for img in "${items[@]}" ; do - # skip non-images... - if [[ "$img" == "${img/.txt/}" ]] ; then - #new="../$IMAGE_HIRES_DIR/`basename ${img/[0-9]-/}`" - new="$IMAGE_HIRES_DIR/`basename ${img/[0-9]-/}`" - # ignore file ext for availability test... - # NOTE: the first match may be an unsupported format... - new="${new%.*}" - new=($new.*) - if [ -e "${new[0]}" ] ; then - items[$C]=${new[0]} - else - echo % - echo "% WARNING: hi-res image not found for: \"${img}\" -> \"${new}\"" | tee >(cat >&2) - echo % - fi - fi - C=$(( C + 1 )) - done - fi - - - # manual layout... - layout=($spread/*layout.tex) - if ! [ -z $layout ] ; then - TEMPLATE=${layout[0]} - - # templates and partial templates... - else - # spread template... - TEMPLATE=($spread/*.tpl) - # skip page template refs: *-imagepage.tpl / *-textpage.tpl - # XXX this will also eat 0-imagepage.tpl / 20-textpage.tpl -- do a better pattern... - if ! [ -z $TEMPLATE ] ; then - TEMPLATE=(`ls "$spread/"*.tpl | egrep -v '.*-(imagepage|textpage)\.tpl'`) - fi - # no template explicitly defined -> match auto-template... - AUTO= - if [ -z $layout ] && [ -z $TEMPLATE ] ; then - AUTO=" (auto)" - if [ ${#items[@]} == 1 ] ; then - TEMPLATE=$SINGLE_IMAGE - - # multiple items... - else - C=0 - for img in "${items[@]}" ; do - C=$(( C + 1 )) - P=`[ $C == 1 ] && echo "left" || echo "right"` - - # image... - if [ "${img/.txt/}" == "${img}" ] ; then - echo % - echo "% $P page (image)..." - TEMPLATE=`getTemplate "$spread" "imagepage"` - echo % page template: $TEMPLATE - anotatePath "${img}" - CAPTION=`getCaption "${img}"` - cat "${TEMPLATE}" \ - | sed "s%\${IMAGE0\?}%${img%.*}%" \ - | sed "s%\${CAPTION0\?}%${CAPTION}%" - - # text... - else - echo % - echo "% $P page (text)..." - TEMPLATE=`getTemplate "$spread" "textpage"` - echo % page template: $TEMPLATE - cat "${TEMPLATE}" \ - | sed "s%\${TEXT}%${img}%" - fi - - # reset for next page... - TEMPLATE= - # only two pages at a time... - [ $C == 2 ] && break - done - fi - fi - # formatting done... - [ -z $TEMPLATE ] && continue - - # format... - TEMPLATE=${TEMPLATE/$spread\//} - TEMPLATE=${TEMPLATE/[0-9]-/} - # get... - TEMPLATE="$TEMPLATE_PATH/${TEMPLATE[0]%.*}.tex" - fi - - # captions... - CAPTION0=`getCaption "${items[0]}"` - CAPTION1=`getCaption "${items[1]}"` - - echo "% template: (template${AUTO}: $TEMPLATE)" - anotatePath "${items[0]}" - - # fill the template... - cat "${TEMPLATE}" \ - | sed "s%\${IMAGE0\?}%${items[0]%.*}%" \ - | sed "s%\${CAPTION0\?}%${CAPTION0}%" \ - | sed "s%\${IMAGE1}%${items[1]%.*}%" \ - | sed "s%\${CAPTION1}%${CAPTION1}%" -done - -echo % -echo % -echo % -echo %---------------------------------------------------------------------- -echo - -echo "Spread created: $c of $l " >&2 - - - -#---------------------------------------------------------------------- -# vim:set ts=4 sw=4 : diff --git a/macros/latex/contrib/photobook/scripts/make-spreads.sh b/macros/latex/contrib/photobook/scripts/make-spreads.sh new file mode 100644 index 0000000000..57be2ff448 --- /dev/null +++ b/macros/latex/contrib/photobook/scripts/make-spreads.sh @@ -0,0 +1,756 @@ +#!/bin/bash +shopt -s nullglob extglob + +#---------------------------------------------------------------------- +# +# TIP: It is better to think of a visual book as a set of spreads +# rather than a set of pages, hence the focus on spreads in the +# code below. +# The main unit of a "visual" book is a spread, it's the thing +# you see when you hold the book open, and the main workflow +# when building a book is creating spreads and ordering them so +# a single page is almost never treated as an independent unit. +# TIP: it is not recommended to use too many templates, the layout +# should be and feel structured and this structure should not be +# too complex for the average reader to get comfortable in. +# +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# +# Template structure: +# templates/ +# spread.tex +# imagepage.tex +# textpage.tex +# ... +# captions/ +# <image>.txt +# image caption. +# this is separated to decouple caption writing from the +# changes to the layout/sequencing and this drastically +# simplify the work with writers. +# For this reason this takes priority over local captions (XXX revise). +# ... +# $SPREADS_DIR/ +# $spread/ +# tweaks.tex +# template tweaks. +# loaded before the templates are handled. +# layout.tex +# manual layout of spread. +# if given rest of directory contents are +# ignored. +# fields: +# ${IMAGE0} +# replaced with image path +# ${CAPTION0} +# replaced with content of caption file if found +# and empty otherwise. +# ${TEXT0} +# replaced with the content of a text file if +# found and empty otherwise. +# ... +# NOTE: if images are included, hi-res source +# substitution is not done here. +# NOTE: fields are ordered and matched according to their +# position and not their number, e.g. in the following +# sequence: +# IMAGE, IMAGE10, IMAGE20, .., +# CAPTION2, CAPTION7, CAPTION12, .. +# IMAGE10 will be filled with the second found image +# and CAPTION7 will be filled with the second found +# caption. +# <spread-template-name>.tpl +# indicates the spread template to use. +# if given the rest of the .tex files in +# directory are ignored. +# resolves to: +# templates/<spread-template-name>.tex +# fields: +# ${IMAGE0} +# ${CAPTION0} +# ${TEXT0} +# ... +# imagepage.tex +# image page template. +# fields: +# ${IMAGE} +# ${CAPTION} +# ${TEXT0} +# ... +# textpage.tex +# text page template. +# fields: +# ${TEXT} +# ... +# <spread-template-name>-imagepage.tpl +# <spread-template-name>-textpage.tpl +# indicates the image/text page template to use. +# ignored if explicit templates are given. +# fields: +# ${IMAGE} +# ${CAPTION} +# ${TEXT} +# ... +# 00-<image>.png +# image. +# if $IMAGE_HIRES_DIR is set then this will +# resolve to: +# $IMAGE_HIRES_DIR/<image> +# supported formats: +# .jpeg, .png, .pdf, .svg, .eps +# (see $IMAGE_FORMATS) +# 00-<image>.txt +# local image caption text. +# NOTE: this must be named the same as the image. +# 01-<text>.txt +# text. +# ... +# ... +# +# +# Env variables: +# ANOTATE_IMAGE_PATHS= +# TEXT_FORMATS=<ext>|.. +# IMAGE_FORMATS=<ext>|.. +# SPREADS_DIR=<path> +# IMAGE_HIRES_DIR=<path> +# sets the path to which the hi-res images are resolved. +# CAPTION_DIR=<path> +# TEMPLATE_DIR=<path> +# EMPTY_PAGE=<name> +# TEXT_PAGE=<name> +# IMAGE_PAGE=<name> +# IMAGE_SPREAD=<array> +# +# +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# +# XXX +# +# +# +#---------------------------------------------------------------------- + +# load config... +CONFIG=${CONFIG:=$(basename ${0%.*}).cfg} +[ -e $CONFIG ] \ + && source "$CONFIG" + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# defaults... +# NOTE: all of these options can be either set in the $CONFIG file or +# set in the script env. +# NOTE: env takes priority over $CONFIG + +# if set add pdf annotations of paths to each image... +ANOTATE_IMAGE_PATHS=${ANOTATE_IMAGE_PATHS:=} + +# supported formats/extensions... +TEXT_FORMATS=${TEXT_FORMATS:=txt} +IMAGE_FORMATS=${IMAGE_FORMATS:=jpeg|jpg|png|pdf|svg|eps} + +SPREADS_DIR=${SPREADS_DIR:=spreads/} +IMAGE_HIRES_DIR=${IMAGE_HIRES_DIR:=} +CAPTION_DIR=${CAPTION_DIR:=captions/} +TEMPLATE_DIR=${TEMPLATE_DIR:=templates/} + +# Default templates +# NOTE: if a template is not found we will try and build a spread from +# page components... + +# page templates... +EMPTY_PAGE=${EMPTY_PAGE:=emptypage} +TEXT_PAGE=${TEXT_PAGE:=textpage} +IMAGE_PAGE=${IMAGE_PAGE:=imagepage} + +# dynamic spread templates... +# NOTE: the index here corresponds to the number of images found in a +# spread directory... +if [ ${#IMAGE_SPREAD[@]} = 0 ] ; then + IMAGE_SPREAD=( + [0]=text-spread + [2]=image-image + ) +fi + + + +#---------------------------------------------------------------------- + +printhelp(){ + echo "Usage: `basename $0` [ARGUMENTS] [PATH]" + echo " `basename $0` [ARGUMENTS] PATH INDEX" + echo " `basename $0` [ARGUMENTS] PATH FROM COUNT" + echo + echo "Generate LaTeX layout from directory structure." + echo + echo "Arguments:" + echo " -h --help - print this help and exit." + echo " -a --annotate" + echo " - add annotations with image paths to pages." + echo " --templates=PATH" + echo " - path to search for templates (default: $TEMPLATE_DIR)." + echo " --single-image-tpl=NAME" + echo " - single image default template (default: ${IMAGE_SPREAD[1]})." + echo " --double-image-tpl=NAME" + echo " - double image default template (default: ${IMAGE_SPREAD[2]})." + echo " --text-spread-tpl=NAME" + echo " - text spread default template (default: ${IMAGE_SPREAD[0]})." + echo " --captions=PATH" + echo " - path to search for captions (default: $CAPTION_DIR)." + echo + echo "Parameters:" + echo " PATH - path to root pages directory (default: $SPREADS_DIR)" + echo " INDEX - index of spread to generate" + echo " FROM - spread to start from" + echo " COUNT - number of spreads to generate" + echo + echo "Environment:" + echo " \$IMAGE_HIRES_DIR " + echo " - source directory for replacement hi-res images." + echo " \$ANOTATE_IMAGE_PATHS " + echo " - if true add image paths in anotations." + echo " \$CONFIG - sets the config file name (default: $CONFIG)" + echo " \$TEXT_FORMATS " + echo " - list of file extensions treated as text (default: $TEXT_FORMATS)." + echo " \$IMAGE_FORMATS " + echo " - list of file extensions treated as images" + echo " (default: $IMAGE_FORMATS)." + echo + echo "Configuration defaults can be stored in a config file: $CONFIG" + echo + echo "NOTE: COUNT is relevant iff FROM is given, otherwise all available " + echo " spreads are generated." + echo + echo "Examples:" + echo " $ `basename $0` ./pages > pages.tex" + echo " - generate a layout fron the contents of ./pages" + echo + echo " $ IMAGE_HIRES_DIR=images/hi-res `basename $0` ./pages" + echo " - generate a layout fron the contents of ./pages and " + echo " replaceing local images with images in ./images/hi-res" + echo +} + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# handle arguments... + +while true ; do + case $1 in + -h|--help) + printhelp + exit + ;; + -a|--annotate) + ANOTATE_IMAGE_PATHS=1 + shift + ;; + + --templates) + TEMPLATE_DIR=$2 + shift + shift + ;; + --single-image-tpl) + IMAGE_SPREAD[1]=$2 + shift + shift + ;; + --double-image-tpl) + IMAGE_SPREAD[2]=$2 + shift + shift + ;; + --text-spread-tpl) + IMAGE_SPREAD[0]=$2 + shift + shift + ;; + --captions) + CAPTION_DIR=$2 + shift + shift + ;; + + # handle unknown options... + -*|--*) + echo "Error: unknown option \"$1\"" + exit + ;; + + *) + break + ;; + esac +done + + +if [ -z $1 ] ; then + SPREADS_DIR=pages/ +else + SPREADS_DIR=$1/ +fi + + +# calculate spread index range... +# XXX add support for negative indexing... +FROM=$2 +COUNT=$( [ -z $3 ] && echo 1 || echo $3 ) +STOP=$(( FROM + COUNT )) + + +# prep format regexps... +TEXT_FORMATS='.*\.('$TEXT_FORMATS')$' +IMAGE_FORMATS='.*\.('$IMAGE_FORMATS')$' + + + +#---------------------------------------------------------------------- + +# Get image caption... +# usage: +# getCaption SPREAD IMAGE +getCaption(){ + local spread=$1 + local name=`basename "${2%.*}"` + + local captions=( + "$CAPTION_DIR/${name}.txt" + "${spread}/${name}.txt" + ) + + local caption + for caption in "${captions[@]}" ; do + if [ -e "${caption}" ] ; then + echo ${caption} + return + fi + done +} + + +# Read/print caption text... +# usage: +# readCaption PATH +readCaption(){ + [ -z "$1" ] \ + && return 1 + cat "$1" \ + | sed -e 's/\\/\\\\\\/g' +} + + +# Get template... +# usage: +# getTemplate SPREAD TYPE +# +getTemplate(){ + local SPREAD=$1 + local TYPE=$2 + local TEMPLATE=($SPREAD/*-$TYPE.tex) + if [ -z $TEMPLATE ] ; then + TEMPLATE=($SPREAD/*-$TYPE.tpl) + if ! [ -z $TEMPLATE ] ; then + TEMPLATE=${TEMPLATE/$SPREAD\//} + TEMPLATE=${TEMPLATE/[0-9]-/} + TEMPLATE="$TEMPLATE_DIR/${TEMPLATE[0]%-${TYPE}.*}.tex" + fi + fi + if [ -z $TEMPLATE ] ; then + TEMPLATE="$TEMPLATE_DIR/${TYPE}.tex" + fi + if ! [ -e $TEMPLATE ] ; then + return + fi + echo $TEMPLATE +} + + +# Get template slots (cached)... +# usage: +# templateSlots TEMPLATE +declare -A TEMPLATE_INDEX +templateSlots(){ + # cache the vars... + #if [ ${TEMPLATE_INDEX[$1]+_} ] ; then + if [ -z ${TEMPLATE_INDEX[$1]} ] ; then + TEMPLATE_INDEX[$1]=$(cat "$1" \ + | grep -o '\${[A-Z0-9_]\+}' \ + | sed 's/\${\(.*\)}/\1/g' \ + | sort -V) + fi + echo ${TEMPLATE_INDEX[$1]} +} + + +# Populate template image/text slots +# usage: +# populateTemplate SPREAD TEMPLATE ITEMS... +# +populateTemplate(){ + local spread="$1" + local tpl="$2" + [ -e "$tpl" ] \ + || return 1 + local slots=( $(templateSlots "${tpl}") ) + local text=$(cat "${tpl}") + + # items/img/txt... + shift 2 + local items=("$@") + if [ ${#items[@]} = 0 ] ; then + items=( $spread/* ) + fi + local img=() + local txt=() + local elem + for elem in "${items[@]}" ; do + if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then + img+=("$elem") + elif [[ "$elem" =~ $TEXT_FORMATS ]] ; then + txt+=("$elem") + fi + done + + local var + local val + local index=() + local captions=() + local name + # pass 1: images... + # NOTE: we are doing this in three passes as caption and image slots + # can be included in the template in any order but the captions + # need all the images to be fully populated/indexed (passes 1 + # and 2), and text is done as a separate pass to prevent it + # from competing with captions. + local i=0 + for var in ${slots[@]} ; do + name=${var//[0-9]/} + if ! [ ${name} = "IMAGE" ] ; then + continue + fi + + val=${img[$i]} + # index images for caption retrieval... + index[${var/$name/}]="$val" + # warn if no image found for slot... + if [ -z ${val} ] ; then + echo % + { + echo "% WARNING: image #${i} requested but not found" + echo "% in: ${tpl}" + echo "% by: ${spread}" + } | tee >(cat >&2) + echo % + fi + i=$(( i + 1 )) + + val=${val//\//\\/} + text=$(echo -e "${text}" | \ + sed "s/\${${var}}/${val%.*}/g") + done + + # pass 2: captions... + for var in ${slots[@]} ; do + name=${var//[0-9]/} + if ! [ ${name} = "CAPTION" ] ; then + continue + fi + + # get global caption... + val=$(getCaption "$spread" "${index[${var/$name/}]}" "${txt[@]}") + + if [ -n "${val}" ] ; then + # clear the used texts... (XXX test) + for i in "${!txt[@]}" ; do + [ "$val" = "${txt[$i]}" ] \ + && unset "txt[$i]" + done + val=$(readCaption "${val}") + fi + + text=$(echo -e "${text}" | \ + sed "s/\${${var}}/${val}/g") + done + + # pass 3: texts... + for var in ${slots[@]} ; do + name=${var//[0-9]/} + if [ ${name} = "CAPTION" ] || [ ${name} = "IMAGE" ] ; then + continue + fi + + val= + for i in ${!txt[@]} ; do + # NOTE: we do not care as much if not text is found... + val=${txt[$i]} + unset "txt[$i]" + # we only need the first text... + break + done + + val=${val//\//\\/} + text=$(echo -e "${text}" | \ + sed "s/\${${var}}/${val}/g") + done + + # print out the filled template... + echo % template: $tpl + echo -e "${text}" + return 0 +} + + +# Handle/print spread... +# usage: +# handleSpread SPREAD +# +# closure: $IMAGE_HIRES_DIR, $IMAGE_SPREAD +handleSpread(){ + local spread="$1" + # skip non-spreads... + [ -d "$spread" ] \ + || return 1 + + # auto layout / templates... + # NOTE: to use a specific template just `touch <template-name>.tpl` + # in the spread directory... + + # layout tweaks... + local tweaks=($spread/*tweak.tex) + if ! [ -z ${tweaks} ] ; then + echo "% tweaks: ${tweaks[0]}" + cat ${tweaks[0]} + fi + + # collect images and text... + # NOTE: we are filling these manually to support configurable + # image/text patterns... + local img=() + local txt=() + local items=() + for elem in "$spread"/* ; do + if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then + img+=("$elem") + items+=("$elem") + elif [[ "$elem" =~ $TEXT_FORMATS ]] ; then + txt+=("$elem") + items+=("$elem") + fi + done + + # get hi-res image paths... + if ! [ -z $IMAGE_HIRES_DIR ] ; then + local C=0 + for image in "${img[@]}" ; do + # skip non-images... + local new="$IMAGE_HIRES_DIR/`basename ${image/[0-9]-/}`" + # ignore file ext for availability test... + # NOTE: the first match may be an unsupported format... + new="${new%.*}" + new=($new.*) + if [ -e "${new[0]}" ] ; then + img[$C]=${new[0]} + else + echo % + echo "% WARNING: hi-res image not found for: \"${image}\" -> \"${new}\"" \ + | tee >(cat >&2) + echo % + fi + C=$(( C + 1 )) + done + fi + + # manual layout... + local template + local layout=( $spread/*layout.tex ) + if ! [ -z $layout ] ; then + template=${layout[0]} + + # templates and partial templates... + else + local template=( $spread/*.tpl ) + # skip page template refs: *-imagepage.tpl / *-textpage.tpl + # XXX this will also eat 0-imagepage.tpl / 20-textpage.tpl -- do a better pattern... + if ! [ -z $template ] ; then + template=(`ls "$spread/"*.tpl \ + | egrep -v '.*-('${IMAGE_PAGE}'|'${TEXT_PAGE}')\.tpl'`) + fi + # no template explicitly defined -> match auto-template... + if [ -z $layout ] && [ -z $template ] ; then + # N images... + if [ -z $template ] && [ -n "${IMAGE_SPREAD[${#img[@]}]}" ] ; then + template=$(getTemplate "$spread" "${IMAGE_SPREAD[${#img[@]}]}") + fi + # build spread from pages... + if [ -z $template ] ; then + local C=0 + local P + local elem + # only one page in spread... + # NOTE since the right page is more important we prioritize + # it over the left page, placing the blank left... + if [ ${#items[@]} = 1 ] ; then + C=1 + echo "%" + echo "% empty page..." + template=$(getTemplate "$spread" "$EMPTY_PAGE") + if [ -z "$teplate" ] ; then + echo "\\null" + echo "\\newpage" + else + cat "${template}" + fi + fi + for elem in "${items[@]}" ; do + C=$(( C + 1 )) + P=$([ $C == 1 ] \ + && echo "left" \ + || echo "right") + + # XXX need to use populateTemplate here... + # ...to do this need to somehow remove the used + # slots/files from list... + + # image... + if [[ "$elem" =~ $IMAGE_FORMATS ]] ; then + echo % + echo "% $P page (image)..." + template=`getTemplate "$spread" "$IMAGE_PAGE"` + echo % template: $template + anotatePath "${elem}" + local caption=$(getCaption "$spread" "${elem}") + caption=$(readCaption "$caption") + cat "${template}" \ + | sed -e "s%\${IMAGE0\?}%${elem%.*}%" \ + -e "s%\${CAPTION0\?}%${caption}%" + # text... + else + echo % + echo "% $P page (text)..." + template=$(getTemplate "$spread" "$TEXT_PAGE") + echo % template: $template + cat "${template}" \ + | sed "s%\${TEXT}%${elem}%" + fi + # reset for next page... + template= + # ignore the rest of the items when we are done + # creating two pages... + [ $C == 2 ] \ + && return 0 + done + fi + fi + # formatting done... + [ -z $template ] \ + && return 0 + + # format template path... + template=${template/$spread\//} + template=${template/[0-9]-/} + # get... + template="${template[0]%.*}.tex" + if ! [ -e "$template" ] ; then + template="$TEMPLATE_DIR/${template[0]%.*}.tex" + fi + fi + + populateTemplate "$spread" "$template" "${img[@]}" "${txt[@]}" + + return 0 +} + + +# Add pdf notes with image path used in template +# usage: +# anotatePath PATH +# +anotatePath(){ + if [ -z "$1" ] || [ -z "$ANOTATE_IMAGE_PATHS" ] ; then + return + fi + path=$(basename ${1%.*}) + # NOTE: did not figure out how to make a verbatim comment in latex + # so here we are, doing it in shell... + path=${path//_/\\_} + #echo "\\pdfmargincomment{Image: $path}%" + echo "\\pdfcommentcell{Image: $path}%" +} + + + +#---------------------------------------------------------------------- +# generate the template... + +echo %---------------------------------------------------------------------- +echo % +echo % WARNING: This file is auto-generated by make-spreads.sh and will be +echo "% overwritten on next run..." +echo % +echo "% Image source (preview): \"$SPREADS_DIR\"" +echo "% Image source (hi-res): \"$IMAGE_HIRES_DIR\"" +echo % +echo %---------------------------------------------------------------------- +echo % + +l=$(ls "$SPREADS_DIR/" | wc -l) +c=0 +d=0 +SPREADS=("$(ls "${SPREADS_DIR}" | sort -n)") +for spread in ${SPREADS[@]} ; do + spread="${SPREADS_DIR}/${spread}" + + # skip non-spreads... + if ! [ -d "$spread" ] ; then + l=$(( l - 1 )) + continue + # skip temporarily disabled... + elif [[ "${spread}" =~ [\\\/]-.*$ ]] ; then + SKIP_FIRST=1 + echo "% spread: ${spread}: skipped..." | tee >(cat >&2) + continue + fi + + c=$(( c + 1 )) + + # if $FROM is given print only stuff in range... + [ -z $FROM ] \ + || if (( $(( c - 1 )) < $FROM )) || (( $c > $STOP )) ; then + continue + fi + + # if we are building only a specific spread... + ##if ! [ -z $SPREAD ] && [[ "$spread" != "$SPREADS_DIR/$SPREAD" ]]; then + ## continue + ##fi + + if ! [ -z $SKIP_FIRST ] ; then + echo % + echo % + echo % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + fi + SKIP_FIRST=1 + + printf "Spread ($c/$l): ${spread} \r" >&2 + echo "% spread: ${spread}" + handleSpread "$spread" + + d=$(( d + 1 )) +done + +echo % +echo % +echo % +echo %---------------------------------------------------------------------- +echo + +echo "Spread created: $d of $l " >&2 + + + +#---------------------------------------------------------------------- +# vim:set ts=4 sw=4 nowrap : |