diff --git a/abbrev.json b/abbrev.json index 3b923b6..dbfce84 100644 --- a/abbrev.json +++ b/abbrev.json @@ -10,19 +10,30 @@ { "alias": "gatherenv", "target": "gather" }, { "alias": "itemenv", "target": "itemize" }, { "alias": "minienv", "target": "minipage" }, - { "alias": "split", "target": "split" }, + { "alias": "spltenv", "target": "split" }, { "alias": "tableenv", "target": "table" }, - { "alias": "tabularenv", "target": "tabular" } + { "alias": "tabularenv", "target": "tabular" }, + { "alias": "tikzpenv", "target": "tikzpicture" }, + { "alias": "detmenv", "target": "vmatrix" }, + { "alias": "matenv", "target": "pmatrix" }, + { "alias": "ctikzenv", "target": "circuitikz" } ], "math": [ { "alias": "prs", "target": "\\left(\\right)?\\i" }, - { "alias": "/", "target": "\\frac{}{}" }, + { "alias": "/", "target": "\\frac{}{}?\\/}i" }, { "alias": "inv", "target": "\\frac{1}{}i" }, { "alias": "txt", "target": "\\text{}i" }, - { "alias": "bks", "target": "\\left{\\right}?\\i" } + { "alias": "bf", "target": "\\mathbf{}i"}, + { "alias": "it", "target": "\\mathit{}i"}, + { "alias": "bks", "target": "\\left{\\right}?\\i" }, + { "alias": "int", "target": "\\int_{}^{} {} d?\\/}i" }, + { "alias": "x", "target": "\\times" }, + { "alias": "*", "target": "\\cdot" } ], "generic": [ { "alias": "cpt", "target": "\\caption{}i" }, + { "alias": "scpt", "target": "\\subcaption{}i" }, + { "alias": "scite", "target": "\\supercite{}i" }, { "alias": "itm", "target": "\\item{}i" }, { "alias": "lbl", "target": "\\label{}i" }, { "alias": "sec", "target": "\\section{}i" }, diff --git a/flake.lock b/flake.lock index 18ec98f..ee2fcd5 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1779560665, - "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", + "lastModified": 1784497964, + "narHash": "sha256-vlHUuqAcbcH2RKmHbPiuQzbv1pnzzavXnI62RD0bqCU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", + "rev": "241313f4e8e508cb9b13278c2b0fa25b9ca27163", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index bc94add..d97ba5d 100644 --- a/flake.nix +++ b/flake.nix @@ -25,16 +25,22 @@ basePackages = [ texEnv + pkgs.fontconfig + pkgs._0xproto pkgs.qpdf pkgs.qpdfview ]; in { + packages = { + inherit texEnv vimWithTex; + }; devShells.default = self.devShells.${system}.latex; devShells.latex = pkgs.stdenv.mkDerivation { inherit name; shellHook = '' export PS1="${name} \w \$ " + export FONTCONFIG_FILE="${pkgs.fontconfig.out}/etc/fonts/fonts.conf" ''; buildInputs = basePackages ++ [ vimWithTex @@ -44,6 +50,7 @@ inherit name; shellHook = '' export PS1="${name} pandoc \w \$ " + export FONTCONFIG_FILE="${pkgs.fontconfig.out}/etc/fonts/fonts.conf" ''; buildInputs = basePackages ++ [ pkgs.pandoc @@ -58,7 +65,11 @@ }; pandoc = { path = ./templates/pandoc; - description = "Template for Pandoc Markdown"; + description = "Template for Pandoc Single File Markdown"; + }; + pandoc-multi = { + path = ./templates/pandoc-multi; + description = "Template for Pandoc Multi-file Markdown"; }; }; defaultTemplate = self.templates.latex; diff --git a/templates/pandoc-multi/Makefile b/templates/pandoc-multi/Makefile new file mode 100644 index 0000000..6eb160d --- /dev/null +++ b/templates/pandoc-multi/Makefile @@ -0,0 +1,27 @@ +PANDOC:=pandoc +TEX:=xelatex + +OUTPUT:=./out + +SRC:=$(wildcard *.md) +SRC_MAIN_TEX:=report.tex +TEX_OUT:=$(SRC:.md=.tex) + +TEMPLATE:=./template.tex + +all: report.pdf + +generate-template: + pandoc --from markdown --to latex --template=${TEMPLATE} -o ${TEMPLATE:.tex=.sty} *.md + sed -i '/====/,/++++/d' ${TEMPLATE:.tex=.sty} + +%.tex: %.md + pandoc --from markdown --to latex --strip-comments -o $@ $^ + +# for multi-file report +report.pdf: ${TEX_OUT} + @mkdir -p ${OUTPUT} + ${TEX} --output-directory=${OUTPUT} ${SRC_MAIN_TEX} + +clean: + rm ${TEX_OUT} diff --git a/templates/pandoc-multi/flake.nix b/templates/pandoc-multi/flake.nix new file mode 100644 index 0000000..d98be89 --- /dev/null +++ b/templates/pandoc-multi/flake.nix @@ -0,0 +1,23 @@ +{ + description = "Template for Pandoc Multi-file Markdown"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + report-temp.url = "github:kenryuS/report-temp"; + }; + + outputs = { self, nixpkgs, flake-utils, report-temp }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + config = {}; + overlays = []; + }; + in + { + devShells.default = report-temp.devShells.${system}.pandoc; + } + ); +} diff --git a/templates/pandoc-multi/part1.md b/templates/pandoc-multi/part1.md new file mode 100644 index 0000000..fb2873e --- /dev/null +++ b/templates/pandoc-multi/part1.md @@ -0,0 +1,15 @@ +# Part 1 + +* Normal +* *Italic* +* **Bold** +* `code` + +> quote + +```python +def fib(n): + if n <= 2: + return 1 + return fib(n - 1) + fib(n - 2) +``` diff --git a/templates/pandoc-multi/part2.md b/templates/pandoc-multi/part2.md new file mode 100644 index 0000000..a7f8064 --- /dev/null +++ b/templates/pandoc-multi/part2.md @@ -0,0 +1,9 @@ +# Part 2 + +1. uno +2. dos +3. tres + +$$ +e^{i\pi} + 1 = 0 +$$ diff --git a/templates/pandoc-multi/report.tex b/templates/pandoc-multi/report.tex new file mode 100644 index 0000000..4c23a10 --- /dev/null +++ b/templates/pandoc-multi/report.tex @@ -0,0 +1,14 @@ +\documentclass[xelatex,ja=standard,11pt]{bxjsarticle} + +\title{テストレポート} +\author{高専太郎} +\date{1970-01-01} + +\usepackage{./template} + +\begin{document} + \maketitle + + \input{part1} + \input{part2} +\end{document} diff --git a/templates/pandoc-multi/template.tex b/templates/pandoc-multi/template.tex new file mode 100644 index 0000000..3b8aca4 --- /dev/null +++ b/templates/pandoc-multi/template.tex @@ -0,0 +1,6 @@ +$passoptions.latex()$ +$common.latex()$ + +==== +$body$ +++++ diff --git a/templates/pandoc/Makefile b/templates/pandoc/Makefile index 345d5cb..a94727a 100644 --- a/templates/pandoc/Makefile +++ b/templates/pandoc/Makefile @@ -1,2 +1,9 @@ +PANDOC:=pandoc +TEX:=lualatex + +OUTPUT:=./out + +all: report.pdf + %.pdf: %.md - pandoc --from markdown --to pdf -o $@ $^ --pdf-engine=lualatex -N + pandoc --from markdown --to pdf -o ${OUTPUT}/$@ $^ --pdf-engine=${TEX} -N diff --git a/templates/pandoc/flake.nix b/templates/pandoc/flake.nix index 2bd8673..05bafe0 100644 --- a/templates/pandoc/flake.nix +++ b/templates/pandoc/flake.nix @@ -1,5 +1,5 @@ { - description = "Template for Pandoc Markdown"; + description = "Template for Pandoc Single File Markdown"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";