aboutsummaryrefslogtreecommitdiff
path: root/tex/src/figure-src-format.tex
blob: ba4458e71e1e180dd403fa8858d6d342cbb2941c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
\begin{tcolorbox}[title=\inlinecode{\textcolor{white}{format.mk}}\hfill(Simplified contents)]
  \footnotesize
  \texttt{\mkcomment{1ST MAKE RULE: build the directory hosting the converted table.}}

  \texttt{\mkvar{a1dir} = \$(\mkvar{BDIR})/format}

  \texttt{\mktarget{\$(a1dir)}:}

  \texttt{\mktab{}\mkprog{mkdir} \$@}

  \vspace{2em}
  \texttt{\mkcomment{2ND MAKE RULE: Convert the XLSX table to a simple plain-text table.}}

  \texttt{\mkvar{mk20tab3} = \$(\mkvar{a1dir})/menke20-table-3.txt}

  \texttt{\mktarget{\$(mk20tab3)}: \$(\mkvar{indir})/menke20.xlsx | \$(\mkvar{a1dir})}

  \texttt{\recipecomment{Call XLSX I/O to convert all the spreadsheets into different CSV files.}}

  \texttt{\recipecomment{We only want the `table-3' spreadsheet, but XLSX I/O doesn't allow setting its}}

  \texttt{\recipecomment{output filename. For simplicity, let's assume its written in `table-3.csv'.}}

  \texttt{\mktab{}\mkprog{xlsxio\_xlsx2csv} \$<}

  \vspace{0.5em}
  \texttt{\recipecomment{Use GNU AWK to keep the desired columns in space-separated, fixed-width format.}}

  \texttt{\recipecomment{With `FPAT' commas within double quotes are not counted as columns.}}

  \texttt{\mktab{}\mkprog{awk} 'NR>1\{printf("\%-10d\%-10d\%-10d \%s\textbackslash{}n", \$\$2, \$\$3, \$\$(NF-1)*\$\$NF, \$\$1)\}' \textbackslash}

  \texttt{\mktab{}{ }{ }{ }{ }FPAT='([\^{},]+)|("[\^{}"]+")' table-3.csv > \$@}

  \vspace{0.5em}
  \texttt{\recipecomment{Delete the temporary CSV file.}}

  \texttt{\mktab{}\mkprog{rm} table-3.csv}

  \vspace{2em}
  \texttt{\mkcomment{3RD MAKE RULE: Main LaTeX macro file for reported values.}}

  \texttt{\mktarget{\$(mtexdir)/format.tex}: \$(\mkvar{mk20tab3)}}

  \texttt{\recipecomment{Count the total number of papers in their study to report in this paper.}}

  \texttt{\mktab{}v=\$\$(\mkprog{awk} '\!/\^{}\#/\{c+=\$\$2\} END\{print c\}' \$(\mkvar{mk20tab3)})}

  \texttt{\mktab{}\mkprog{echo} "\textbackslash{}newcommand\{\textbackslash{}menkenumpapers\}\{\$\$v\}" > \$@}

  \vspace{0.5em}
  \texttt{\recipecomment{Count total number of journals in that study.}}

  \texttt{\mktab{}v=\$\$(awk 'BEGIN{FIELDWIDTHS="31 10000"} !/\^\#/\{print \$\$2\}' \$(mk20tab3) \textbackslash}

  \texttt{\mktab{ }{ }{ }{ }{ }{ }{ }{ }{ }{ }| uniq | wc -l)}

  \texttt{\mktab{}\mkprog{echo} "\textbackslash{}newcommand\{\textbackslash{}menkenumjournals\}\{\$\$v\}" >> \$@}
\end{tcolorbox}