Last active
October 12, 2018 13:48
-
-
Save nekketsuuu/48834bada5febf1ac3b745695461ca55 to your computer and use it in GitHub Desktop.
最新版のコードはこちら: https://github.com/nekketsuuu/satysfi-matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdjabook | |
@import: matrix | |
document (| | |
title = {\SATySFi;で行列}; | |
author = {\@nekketsuuu}; | |
show-title = false; | |
show-toc = false; | |
|) '< | |
+math(${ | |
P | |
\matrix!([ | |
[${1}; ${2}; ${3}]; | |
[${4}; ${5}; ${6}]; | |
[${7}; ${8}; ${9}]; | |
]) | |
Q | |
}); | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: math | |
@require: table | |
module Matrix : sig | |
direct \matrix : [(math list) list] math-cmd | |
end = struct | |
let-math \matrix mss = | |
let body = text-in-math MathInner (fun ctx -> ( | |
let size = get-font-size ctx in | |
let pads = (0pt, 0pt, size *' 0.25, size *' 0.25) in | |
let pads-top = (0pt, 0pt, 0pt, size *' 0.25) in | |
let pads-bottom = (0pt, 0pt, size *' 0.25, 0pt) in | |
let pads-single = (0pt, 0pt, 0pt, 0pt) in | |
let cell-of-m pads m = NormalCell(pads, inline-skip size ++ embed-math ctx m ++ inline-fil) in | |
let cells-of-ms pads ms = | |
(match ms with | |
| [] -> [] | |
| m :: ms -> | |
(let leftmost = NormalCell(pads, embed-math ctx m ++ inline-fil) in | |
let rest = List.map (cell-of-m pads) ms in | |
leftmost :: rest)) | |
in | |
let-rec cellss-of-mss-tail mss = | |
(match mss with | |
| [] -> [] | |
| ms :: [] -> [cells-of-ms pads-bottom ms] | |
| ms :: mss -> (cells-of-ms pads ms) :: (cellss-of-mss-tail mss)) | |
in | |
let cellss = | |
(match mss with | |
| [] -> [] | |
| ms :: [] -> [cells-of-ms pads-single ms] | |
| ms :: mss -> (cells-of-ms pads-top ms) :: (cellss-of-mss-tail mss)) | |
in | |
let grf = fun _ _ -> [] in | |
let ib = tabular cellss grf in | |
let (_, height, depth) = get-natural-metrics ib in | |
let hgtaxis = get-axis-height ctx in | |
let rising = hgtaxis -' (height +' depth) *' 0.5 in | |
raise-inline rising ib)) | |
in math-paren Math.paren-left Math.paren-right body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment