tikz
By Sigmund Tzeng
- 1 babel
- 1.1 tikz 設定,記得 exports both才能圖碼俱現
- 1.2 tikz0 可預覽,亦可匯出為 pdf 或 html
- 1.3 tikz2
- 1.4 Graph Drawing - PGF/TikZ Manual
- 1.5 FSM
- 2 preview / export
- 2.1 tikz3
- 2.1.1 not ok
- 2.2 tikz4
- 2.3 tikz5
- 2.4 tikz6
預覽時 chemfig 不行,但匯出可
- 2.1 tikz3
- 3 Plots of Functions - PGF/TikZ Manual
1 babel
1.1 tikz 設定,記得 exports both才能圖碼俱現
參 Exporting Code Blocks (The Org Manual) ,其它選項有 code, results, none
\begin{tikzpicture}[domain=-2:2,samples=100,scale=1.0,>=latex]
\tikzset{bgrid/.style={help lines,color=blue!10,very thin}}
\draw[bgrid] (-1.5,-3.5) grid (7.5,3.5);
\draw[<->, color=black] (-1.5,0) -- (7.5,0) node[right] {$x$};
\draw[<->, color=black] (0,-3.5) -- (0,3.5) node[above] {$y$};
\foreach \x/\xtext in {-1,1,2,3,4,5,6,7}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\xtext$};
\foreach \y/\ytext in {-3,-2,-1,1,2,3}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\ytext$};
\draw[thick,color=black,domain=0:7.5,smooth]plot (\x,{sqrt(\x)}) node[anchor=south] {$y = \sqrt{x}$};
\draw[dashed,color=black,domain=0:7.5,smooth]plot (\x,{(-1)*(sqrt(\x))}) node[anchor=north] {$y = -\sqrt{x}$};
%\draw[thick,color=black,domain=-1.5:5.5,samples=3]plot (\****)-2}) node[anchor=south] {$y = {x} - 2$};
\filldraw[black] (4,2) circle(2pt) node[anchor=south east] {$(4, 2)$};
\filldraw[red] (1,-1) circle(2pt);
\draw[red] (1.5,-1) node[anchor=west] {$(1, -1)$};
\end{tikzpicture}
1.2 tikz0 可預覽,亦可匯出為 pdf 或 html
Set up the TikZ in Emacs Org | MSC
1.3 tikz2
1.4 Graph Drawing - PGF/TikZ Manual
1.5 FSM
Automata Drawing Library - PGF/TikZ Manual
2 preview / export
2.1 tikz3
2.1.1 not ok
2.2 tikz4
目前預覽或匯出為pdf是ok的,指令/組合鍵為:C-c C-e C-s l o。匯出 html 則只有單行的 latex 能成功
2.3 tikz5
For MiKTEX, use the update wizard to install the (latest versions of the) packages called pgf, xcolor, and xkeyval. 但是預設已經都安裝了
(org-babel-do-load-languages ‘org-babel-load-languages ‘((latex . t))) ;手動加在設定檔中,這使得 babel 可以執行,但仍無正確出圖
(add-to-list ‘org-latex-packages-alist ‘("" “tikz” t)) ;這個部分檔頭已經有宣告,沒有必要了 org-latex-default-packages-alist org-format-latex-header
(setq org-latex-create-formula-image-program ‘imagemagick) ;dvipng? 目前未安裝 imagemagick
tikz pgf - Why are my characters overlapping? - TeX - LaTeX Stack Exchange dvipng 輸出的圖會纏在一起
Using the tex:dvipng option - exporter does not find tikz package : orgmode
(setq org-latex-create-formula-image-program ‘dvisvgm) (setq org-preview-latex-default-process ‘dvisvgm) ;dvipng
但是檔名必需設為 png ??? 設為 svg 完全無法產生圖檔,是為何??? 可能的說明在以下連結
latex block tikz to svg 原作者應為 Edouard Debry,簡單來說就是要改 ob-latex.el
subject:“Re\: latex block tikz to svg”
Pdftex: Inkscape svg to pdflatex code example 這篇寫得亂七八糟,感覺是 ai 寫的
2.3.1 改 ob-latex.el 把 png 改成 svg
((and (string-suffix-p ".png" out-file) (not imagemagick)) <br/>
改成 ((and (string-suffix-p “.svg” out-file) (not imagemagick))
2.3.2 set git bash as shell in emacs 似乎沒有影響
(setq binary-process-input t) ;??? (setq w32-quote-process-args ?\") ;??? (setenv “SHELL” shell-file-name) ;這好像要設? (setq explicit-shell-file-name “C:/Program Files/Git/git-bash.exe”) ;原值為nil (setq explicit-sh-args ‘("-login" “-i”)) ;???
2.4 tikz6 預覽時 chemfig 不行,但匯出可
3 Plots of Functions - PGF/TikZ Manual
TikZ and pgf Manual for version 1.18