LoginSignup
4
4

More than 5 years have passed since last update.

続 pandoc をつかって markdown で簡単にレポート的なものをつくる

Posted at

昨日書いた記事の、レポートをつくるためのもろもろのものを生成するシェルスクリプトを書いた。
pandoc をつかって markdown で簡単にレポート的なものをつくる

makerepo.sh
#!/bin/sh

dirName=$1

if test $# -ne 1; then
    echo "pleas dir name"
    return 0
fi

makefile=$dirName/makefile
contents=$dirName/contents.md
main=$dirName/main.tex

echo -n "report name? : "
read reprotname
echo -n "author name? : "
read author

makefiletxt="TEX=platex
DVI2PDF=dvipdfmx
MKDFILE=contents.md
ROWTEX=rowtex.tex
TEXFILE=contents.tex

SOURCES=main.tex

all: makexbb md2tex converttex dvi2pdf clean

makexbb:
    @extractbb *.png

md2tex:
    @pandoc \$(MKDFILE) -o \$(ROWTEX)

converttex: \$(ROWTEX)
    @cat \$^ \\\\
    | sed 's/includegraphics/includegraphics[width=1.0\\\\\\\\columnwidth]/g' \\\\
    > \$(TEXFILE)

.tex.dvi: main.tex
    @\${TEX} \$<
    @\${TEX} \$<

dvi2pdf: \$(SOURCES:.tex=.dvi)
    @\${DVI2PDF} \$^

clean:
    @rm -f *.dvi *.aux *.log \$(ROWTEX)"

maintext="\\\\documentclass[11pt,a4paper]{jsarticle}

\\\\usepackage{amsmath,amssymb}
\\\\usepackage{bm}
\\\\usepackage{ascmac}
\\\\usepackage[dvipdfmx]{graphicx,color}
\\\\usepackage{longtable}
\\\\usepackage{booktabs}

\\\\title {$reprotname}
\\\\author {$author}

\\\\begin {document}
\\\\maketitle
\\\\input {contents}
\\\\end{document}"


mkdir $dirName
touch $makefile
touch $contents
touch $main

echo $makefiletxt > $makefile
echo $maintext > $main

こんなかんじになる。

% mkrepo.sh dirname
report name? : レポートタイトル
author name? : 書いたひと
% cd dirname
% ls
contents.md  main.tex  makefile
% make
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4