|
| 1 | +# LibTeXPrintf |
| 2 | + |
| 3 | +[](https://github.com/Suavesito-Olimpiada/LibTeXPrintf.jl/actions) |
| 4 | +[](https://codecov.io/gh/Suavesito-Olimpiada/LibTeXPrintf.jl) |
| 5 | + |
| 6 | + |
| 7 | +Wrapper of the library |
| 8 | +[bartp5/libtexprintf](https://github.com/bartp5/libtexprintf) for |
| 9 | +printing rendered LaTeX code in the terminal. |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +To install LibTeXPrintf.jl, in the Julia REPL |
| 14 | + |
| 15 | +```julia |
| 16 | +julia> using Pkg |
| 17 | +julia> Pkg.add("LibTeXPrintf") |
| 18 | +``` |
| 19 | + |
| 20 | +# Documentation |
| 21 | + |
| 22 | +LibTeXPrintf.jl export six three functions |
| 23 | + |
| 24 | +```julia |
| 25 | +texfonts()::NTuple(N, String) |
| 26 | +texgetfont()::String |
| 27 | +texsetfont(font::String)::String |
| 28 | + |
| 29 | +texsymbols()::ImmutableDict{String, String} |
| 30 | + |
| 31 | +stexprintf(format::String, args...)::String |
| 32 | +stexprintf(format::LaTeXString, args...; clean=true)::String |
| 33 | + |
| 34 | +texprintf([io::IO], format::String, args...) |
| 35 | +texprintf([io::IO], format::LaTeXString, args...; clean=true) |
| 36 | +``` |
| 37 | + |
| 38 | +The documentation of every one of these can be consulted in help mode in the |
| 39 | +REPL (press `?` to change to help mode, `backspace` to exit). |
| 40 | + |
| 41 | +### Format string |
| 42 | + |
| 43 | +The `format` positional argument is interpreted as $\LaTeX$ code, but with the |
| 44 | +extra that format specifiers of `@printf` (or the `printf` function in the |
| 45 | +C language) are allowed inside. |
| 46 | + |
| 47 | +The argument `format` can also be a `LaTeXString`, from |
| 48 | +[LaTeXStrings.jl](https://github.com/stevengj/LaTeXStrings.jl), in which case |
| 49 | +the keyword argument `clean` is present (and defaults to `true`). When |
| 50 | +`clean=true`, then format is changed into `strip(format, '$')`. |
| 51 | + |
| 52 | +**Note** |
| 53 | +: If you try to print a new line character in (`'\n'`) inside a |
| 54 | + `LaTeXString`, it will error saying `ERROR: ArgumentError: Unknown command |
| 55 | + (1x)`. This is because LaTeXStrings.jl escapes the string from `"\n"` to |
| 56 | + `"\\n"` and when libtexprintf sees it, it looks like a LaTeX command, just |
| 57 | + not one that it knows about. |
| 58 | + |
| 59 | + There is also the problem that libtexprintf will actually just **ignore** |
| 60 | + all the new line characters (`'\n'`). |
| 61 | + |
| 62 | +## Examples |
| 63 | + |
| 64 | +```julia |
| 65 | +julia> using LibTeXPrintf |
| 66 | + |
| 67 | +julia> using LaTeXStrings |
| 68 | + |
| 69 | +julia> texprintf("\\\\frac{1}{%d}", 2) |
| 70 | +1 |
| 71 | +─ |
| 72 | +2 |
| 73 | + |
| 74 | +julia> texprintf("\\\\sum_{i=0}^{10}{%c}^2", 'i') |
| 75 | +10 |
| 76 | +⎯⎯ |
| 77 | +╲ 2 |
| 78 | +╱ i |
| 79 | +⎺⎺ |
| 80 | +i=0 |
| 81 | + |
| 82 | +julia> texsetfont("mathbb") |
| 83 | +"mathbb" |
| 84 | + |
| 85 | +julia> texprintf("This is a LaTeX string.") |
| 86 | +𝕋𝕙𝕚𝕤 𝕚𝕤 𝕒 𝕃𝕒𝕋𝕖𝕏 𝕤𝕥𝕣𝕚𝕟𝕘. |
| 87 | + |
| 88 | +julia> texsetfont("text") |
| 89 | +"text" |
| 90 | + |
| 91 | +julia> texprintf("This is a LaTeX string.") |
| 92 | +"This is a LaTeX string." |
| 93 | +``` |
| 94 | + |
0 commit comments