Commit 0f112ab7 authored by whywaita's avatar whywaita
Browse files

Initial Commit

parents
Pipeline #2627111 passed with stage
image: whywaita/docker-latex-jlisting:latest
before_script:
- ruby --version
media:
stage: build
script:
- cd media
- mkdir tmp
- mkdir output
- rake
artifacts:
paths:
- ./media/output/report.pdf
source 'https://rubygems.org'
gem 'rake'
GEM
remote: https://rubygems.org/
specs:
rake (10.3.1)
PLATFORMS
ruby
DEPENDENCIES
rake
# MICS Report - Rakefile
require 'yaml'
SRC = "tex"
TMP = "tmp"
OUTPUT = "output"
CONFIG = "config"
LIB = "lib"
CODE = "src"
IMAGES = "images"
# init / reset project files
task :init do
`mkdir #{SRC}`
`mkdir #{TMP}`
`mkdir #{OUTPUT}`
`mkdir #{CONFIG}`
`mkdir #{CODE}`
`mkdir #{IMAGES}`
`cp #{LIB}/title.yml.sample #{CONFIG}/title.yml`
`touch #{CONFIG}/tex_files`
`touch #{TMP}/title.tex`
`touch #{TMP}/body.tex`
`touch #{TMP}/footer.tex`
`echo "\\end{document}" > #{TMP}/footer.tex`
`git remote remove origin`
end
task :reset do
`rm -rf #{SRC}`
`rm -rf #{TMP}`
`rm -rf #{OUTPUT}`
`rm -rf #{CONFIG}`
`rm -rf #{CODE}`
`rm -rf #{IMAGES}`
end
# create new .tex file
task :create do
if ENV['name'].nil?
puts "ERROR: NO NAME"
puts "execute `rake create name=NAME`"
exit
end
`touch #{SRC}/#{ENV['name']}.tex`
`echo #{ENV['name']}.tex >> #{CONFIG}/tex_files`
end
task :make_title do
title = YAML.load_file("#{CONFIG}/title.yml")
`cat #{LIB}/title.tex > #{TMP}/title.tex`
`echo '\\\\title{#{title['title']}}' >> #{TMP}/title.tex`
`echo '\\\\author{#{title['name']}}' >> #{TMP}/title.tex`
`echo '\\\\\date{\\\\today}' >> #{TMP}/title.tex`
`echo '\\\\thesis{#{title['thesis']}}' >> #{TMP}/title.tex`
`echo '\\\\id{#{title['stdid']}}' >> #{TMP}/title.tex`
`echo '\\\\course{#{title['course']}}' >> #{TMP}/title.tex`
`echo '\\\\begin{document}' >> #{TMP}/title.tex`
`echo '\\\\maketitle' >> #{TMP}/title.tex`
`echo '\\\\clearpage' >> #{TMP}/title.tex`
end
task :make_body do
cmd = ["cat"]
open "#{CONFIG}/tex_files" do |file|
while l = file.gets
cmd << "#{SRC}/#{l.chomp}"
end
end
`#{cmd.join(" ")} > #{TMP}/body.tex` if cmd.size > 1
`cp #{CODE}/* #{TMP}/`
`cp #{IMAGES}/*.png #{TMP}/`
`cp #{IMAGES}/*.jpg #{TMP}/`
`cp #{IMAGES}/*.eps #{TMP}/`
`cd #{TMP} && extractbb *.png`
end
task :concat do
`cat #{TMP}/title.tex #{TMP}/body.tex #{TMP}/footer.tex > #{TMP}/report.tex`
end
task :make_pdf do
`cd #{TMP} && platex report.tex && platex report.tex`
`cd #{TMP} && dvipdfmx report.dvi`
`mv #{TMP}/report.pdf #{OUTPUT}/report.pdf`
end
task :make_pdf_debug do
sh "cd #{TMP} && platex report.tex && platex report.tex"
`cd #{TMP} && dvipdfmx report.dvi`
`mv #{TMP}/report.pdf #{OUTPUT}/report.pdf`
end
task :compile => [:make_title, :make_body, :concat, :make_pdf]
task :default => :compile
thesis: 文学少女入門
title: レポート
name: 橘 和板
stdid: 9999999
course: 幼女コース
\documentclass[a4j,10pt]{jarticle}
% title
\makeatletter
\def\thesis#1{\def\@thesis{#1}}
\def\id#1{\def\@id{#1}}
\def\course#1{\def\@course{#1}}
\def\@maketitle{
\begin{center}
{\huge \@thesis \par}
\vspace{10mm}
{\LARGE\bf \@title \par}
\vspace{10mm}
{\Large \@date\par}
\vspace{20mm}
{\large \@course \par}
\vspace{2mm}
{\large \@id \hspace{3mm} \@author \par}
\end{center}
\par\vskip 1.5em
}
\makeatother
% packages
\usepackage[dvipdfmx]{graphicx}
\usepackage{listings,jlisting}
\usepackage[dvipdfmx]{color}
\lstset{%
frame=single,
stringstyle={\ttfamily \color[rgb]{0,0,1}},
commentstyle={\itshape \color[cmyk]{1,0,1,0}},
identifierstyle={\ttfamily},
keywordstyle={\ttfamily \color[cmyk]{0,1,0,0}},
basicstyle={\ttfamily},
breaklines=true,
xleftmargin=0zw,
xrightmargin=0zw,
framerule=.2pt,
columns=[l]{fullflexible},
numbers=left,
stepnumber=1,
numberstyle={\scriptsize},
numbersep=1em,
showstringspaces=\false,
keepspaces=true,
language={C},
lineskip=-0.5zw,
morecomment={[s][{\color[cmyk]{1,0,0,0}}]{/**}{*/}},
}
thesis: (講義名)
title: (レポートのタイトル)
name: (名前)
stdid: (学籍番号)
course: (コース名)
\section{がいよう!}
このぶんしょうをかくことで、ぶんがくしょうじょめざすの!
\section{みだし!}
\subsection{つぎのみだし!}
#!/bin/sh
set -euo pipefail
REPORT_NAME=$1
git clone https://github.com/kakakaya/mics_report ${REPORT_NAME}
rm -rf ${REPORT_NAME}/.git
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment