Skip to content

Commit

Permalink
Support draw.io
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyaonoe committed Jan 6, 2025
1 parent 53b7046 commit 0a3a7e5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,5 @@ TSWLatexianTemp*
#*Notes.bib

*.pdf
!images/**/*.pdf
main-diff.tex
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CLEAN = *.aux *.blg *.fdb_latexmk *.fls *.log *.out *.pdf *.synctex.gz *.toc *.dvi main-diff.tex
IMAGE = $(shell find . -name '*.drawio.png')

MDTOPDF = md-to-pdf
DRAWIO = /Applications/draw.io.app/Contents/MacOS/draw.io

.PHONY: all
all: main.pdf

main.pdf: main.tex main.bib $(IMAGE:%.drawio.png=%.pdf)
latexmk -g main.tex

.PHONY: diff
diff: main-diff.pdf

main-diff.pdf main-diff.tex: main.tex main.bib
./script/latexdiff.sh $(VERSION)
@echo VERSION = $(VERSION)

.PHONY: images
images: $(IMAGE:%.drawio.png=%.pdf)

%.pdf: %.drawio.png
$(DRAWIO) --export --format pdf --crop -o $@ $^

.PHONY: clean/images
clean/images:
- $(RM) $(IMAGE:%.drawio.png=%.pdf)

.PHONY: clean
clean:
- $(RM) -r $(CLEAN)
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ This repository is a template for writing and building documents with LaTeX.
Please write documents in `main.tex`.
If you want to use bibtex, you can write references in `main.bib`.

### images
You can use draw.io to create images.
First, please install draw.io desktop app from [here](https://github.com/jgraph/drawio-desktop/releases).
Next, please update `DRAWIO` in `Makefile` to the path of draw.io desktop app.
You can create `images/<name>.drawio.png` and run `make images` to generate `images/<name>.pdf`.

### latexdiff
You can check diff with latexdiff.

When you run below command, `main-diff.pdf` will be built.
```
./script/latexdiff.sh <commit hash (HEAD if you do not specify it)>
make main-diff.pdf <commit hash (HEAD if you do not specify it)>
```

## Outputs
### local
You can see `main.pdf` by running command `latexmk`.
You can see `main.pdf` by running command `make`.

### remote
This repository builds PDF with GitHub Action and [container-texlive](https://github.com/hiroyaonoe/container-texlive).
Expand Down
Binary file added images/example.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example.pdf
Binary file not shown.
9 changes: 9 additions & 0 deletions main.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
\documentclass[a4paper,11pt,uplatex,dvipdfmx]{article}

\usepackage{graphicx}

\begin{document}

\title{LaTeX Template}
Expand All @@ -9,6 +11,13 @@

This repository is a template for writing and building documents with LaTeX. Please see README.md\cite{latex-template} for the usage.

\begin{figure}[htb]
\centering
\includegraphics[keepaspectratio, width=\hsize]{images/example.pdf}
\caption{example image}
\label{fig: example}
\end{figure}

\bibliography{main}
\bibliographystyle{unsrt}
\end{document}

0 comments on commit 0a3a7e5

Please sign in to comment.