improve includeDiagram macro

This commit is contained in:
Oystein Kristoffer Tveit 2021-05-03 01:05:50 +02:00
parent 65af5f0d97
commit eaf9ceea28
2 changed files with 67 additions and 27 deletions

View File

@ -6,6 +6,7 @@
\RequirePackage{pgfplots}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{ntnu}
% ░█▀▀░▄▀▄░█░█░█▀█░▀█▀░▀█▀░█▀█░█▀█░█▀▀
@ -27,27 +28,6 @@
% ░█░█░█▀▄░█▀█░█▀▀░█▀█░▀▀█
% ░▀▀▀░▀░▀░▀░▀░▀░░░▀░▀░▀▀▀
\RequirePackage{tcolorbox}
\newtcolorbox{coloredgraphbox}[1][]{
colframe=ntnublue,
arc=0pt,
outer arc=0pt
colback=white,
boxrule=3pt,
#1
}
%TODO: Make resizable and float
\newenvironment{mgraphbox}[1][]{
\begin{center}
\begin{coloredgraphbox}[#1]
}{
\end{coloredgraphbox}
\end{center}
}
%TODO: Directed graphs, trees
% ░▀█▀░█▀█░█▀▄░█░░░█▀▀░█▀▀

View File

@ -182,13 +182,31 @@
\addcontentsline{toc}{subsubsubsection}{\theenumiii}
}
% ░█▀▄░▀█▀░█▀█░█▀▀░█▀▄░█▀█░█▄█░█▀▀
% ░█░█░░█░░█▀█░█░█░█▀▄░█▀█░█░█░▀▀█
% ░▀▀░░▀▀▀░▀░▀░▀▀▀░▀░▀░▀░▀░▀░▀░▀▀▀
% ░█▄█░▀█▀░█▀▀░█▀▀
% ░█░█░░█░░▀▀█░█░░
% ░▀░▀░▀▀▀░▀▀▀░▀▀▀
\RequirePackage{xparse}
\RequirePackage{xkeyval}
\newtcolorbox{coloredgraphbox}[1][]{
colframe=ntnublue,
arc=0pt,
outer arc=0pt
colback=white,
boxrule=3pt,
#1
}
%TODO: Make resizable and float
\newenvironment{mgraphbox}[1][]{
\begin{center}
\begin{coloredgraphbox}[#1]
}{
\end{coloredgraphbox}
\end{center}
}
\RequirePackage{float}
\RequirePackage[export]{adjustbox}
\newcommand{\pic}[1]{
\begin{figure}[H]
@ -196,7 +214,49 @@
\end{figure}
}
\ProcessOptions\relax
\newcommand{\@ifdefined}[2]{
\@ifundefined{#1}{}{#2}
}
\define@key{inputDiagram}{width}{\def\id@width{#1}}
\define@key{inputDiagram}{scale}{\def\id@scale{#1}}
\define@key{inputDiagram}{caption}{\def\id@caption{#1}}
\define@key{inputDiagram}{label}{\def\id@label{#1}}
\define@boolkey{inputDiagram}{pdf}{}
\NewDocumentCommand{\includeDiagram}{ o m }{
\begingroup
\setkeys{inputDiagram}{width=\linewidth, scale=1, pdf=false}
\IfValueT{#1}{\setkeys{inputDiagram}{#1}}
\begin{mgraphbox}[width=\id@width]
\begin{figure}[H]
\begin{center}
\scalebox{\id@scale}{
\ifKV@inputDiagram@pdf
\includegraphics{#2}
\else
\input{#2}
\fi
}
\@ifdefined{id@caption}{\caption{\id@caption}}
\@ifdefined{id@label}{\label{\id@label}}
\end{center}
\end{figure}
\end{mgraphbox}
\endgroup
}
% ░█▄█░▀█▀░█▀▀░█▀▀
% ░█░█░░█░░▀▀█░█░░
% ░▀░▀░▀▀▀░▀▀▀░▀▀▀
\RequirePackage{float}
\RequirePackage[export]{adjustbox}
\setlength{\parindent}{0cm}