summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ditaa/ditaa.sty
blob: 21969353dce2f7bef6af784e1c29e244cc8fe1ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% 'ditaa' package
%
% (c) Hiroshi Ukai
%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ditaa}
[2018/09/27 v0.01 LaTeX package for embedding ditaa style ascii art]

\RequirePackage{fancyvrb}
\RequirePackage{graphicx}
\RequirePackage{kvoptions}

\DeclareStringOption[]{imagepath}
\ProcessKeyvalOptions*

%@formatter:off (This line indicates IntelliJ that formatter should be off before this)
\newenvironment{ditaa}[3][\columnwidth]
    {
        \def\ditaacaption{#2}
        \def\ditaastem{#3}
        \def\ditaadir{\ditaa@imagepath/ditaa}
        \def\ditaafile{\ditaadir/\ditaastem.ditaa}
        \def\ditaafigwidth{#1}
        \VerbatimOut{\ditaafile}}
    {\endVerbatimOut
        \immediate\write18{ditaa -E "\ditaafile" "\ditaadir/\ditaastem.png"}
        \begin{figure}[ht]
            \begin{center}
                \vspace{-1em}
                \includegraphics[width=\ditaafigwidth]{\ditaadir/\ditaastem.png}
                \vspace{-2em}
                \caption{\ditaacaption}
                \label{fig:\ditaastem}
                \vspace{-1.5em}
            \end{center}
        \end{figure}
    }
%@formatter:on (This line indicates IntelliJ that formatter should be off before this)
%--------------------------------------------------

\endinput
%%
%% End of file `ditaa.sty'.