Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
, pugixml
, qtbase
, wrapQtAppsHook
, fetchzip
, runCommand
, withPortabilityTweaks ? false
}:

Expand Down Expand Up @@ -41,7 +43,47 @@ stdenv.mkDerivation {
git
wrapQtAppsHook
(texlive.combine {
inherit (texlive) scheme-small standalone pgfplots;
inherit (texlive) scheme-small standalone pgfplots unicode-math;
# https://ctan.org/tex-archive/fonts/lete-sans-math
# TODO use buildTeXLivePackage
# lete-sans-math = pkgs.texlivePackages.buildTeXLivePackage {
## revision = 64540;
# shortdesc = "Lato-based OpenType Math font for LuaTeX and XeTeX";
## stripPrefix = 0;
## fontMaps = [
## "Map andika.map"
## ];
## sha512.run = "4da9904459345033aa87deeb0019c8c4a39fbafcd59d973717ed2c4a410ece528944c69669b6a5ecf6ef8bb790f60bba909468e001485c405e7cf8775b7533e5";
## sha512.doc = "50684857dc25ad942aff18eedec04c9e27e4e408f748c208f8527c5096e600d26769ec6f82e2f02e72ab472dfb662f12bb009156293a12daa2dc0676d63ed446";
# hasRunfiles = false;
# license = [ "lppl13c" ];
# version = "0.41";
# };
lete-sans-math = {
pkgs = [
(runCommand "lete-sans-math" {
src = fetchzip {
url = "https://mirrors.ctan.org/fonts/lete-sans-math.zip";
# url = "https://raw.githubusercontent.com/abccsss/LeteSansMath/refs/tags/v0.41/lete-sans-math.sty";
# url = "https://raw.githubusercontent.com/PierreSenellart/apxproof/1ac14c47b8351b693ca05eec73dca1332a517ac9/apxproof.sty";
# sha256 = "sha256-XSgtXsOwhMu2Wo4hVp8ZfaPWgjEEg3EBn5/BhD3xkMA=";
# hash = "sha256-aUKS2tCbC+eBFPMSJuzzkWgFkSqWnizekTOnoK2f5L4=";
hash = "sha256-pz5qKo4ALYuTjGeO9YqxB6hcrqIkT4S8U28cLMZdG5U=";
};
passthru = {
pname = "lete-sans-math";
version = "0.45";
tlType = "run";
};
} ''
mkdir -p \
$out/tex/latex/lete-sans-math/ \
$out/fonts/opentype/public/lete-sans-math/
cp $src/*.sty $src/*.ltx $out/tex/latex/lete-sans-math/
cp $src/*.otf $out/fonts/opentype/public/lete-sans-math/
'')
];
};
})
];

Expand Down
1 change: 1 addition & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_custom_target( doc )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/latex" )

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/openemsh.1.in"
Expand Down
13 changes: 13 additions & 0 deletions doc/latex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if( CMakeUtils_Latex_FOUND )
compile_latex_file( "interval" REGISTER_TO "LATEX_FILES" VERBOSE )

add_custom_target( "latex" DEPENDS ${LATEX_FILES} )
add_dependencies( "doc" "latex" )

install(
FILES
${LATEX_FILES}
DESTINATION "${CMAKE_INSTALL_DOCDIR}/openemsh"
OPTIONAL
)
endif()
235 changes: 235 additions & 0 deletions doc/latex/interval.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
\documentclass[tikz]{standalone}

%\usepackage{etoolbox}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX, Mapping=tex-text]{Lato}
%\usepackage[default]{lato}
\usepackage{unicode-math}
%\setmathfont{Lete Sans Math}
\setmathfont{LeteSansMath.otf}
%\usepackage{lete-sans-math}
\usepackage{tikz}
\usetikzlibrary{math}
\usepackage{xfp}

\begin{document}
\begin{tikzpicture}

\def\width{10}
\def\height{5}
\def\ox{\fpeval{\width /2}}
\def\oy{\fpeval{\height /2}}
\coordinate (O) at (\ox,\oy);

\tiny
\path [use as bounding box] (0,0) rectangle (\width,\height);

% SHAPE
%\filldraw [line width=0.5pt, fill=orange] (\ox,\oy)
% +(-0.5,-0.5) node[draw, fill=black, circle, inner sep=1pt] {} node[below left] {0} --
% +(0.5,-0.5) node[draw, fill=black, circle, inner sep=1pt] {} node[below right] {1} --
% +(0.5,0.5) node[draw, fill=black, circle, inner sep=1pt] {} node[above right] {2} --
% +(-0.5,0.5) node[draw, fill=black, circle, inner sep=1pt] {} node[above left] {3} --
% cycle;

% PORTS
%\draw [line width=2pt] (\ox,\oy) ++(-0.5,0) node[right] {1} +(0,-0.5) -- +(0,0.5);
%\draw [line width=2pt] (\ox,\oy) ++(0,-0.5) node[above] {2} +(-0.5,0) -- +(0.5,0);



% MID LINE
\draw [line width=0.5pt, dotted] (O) +(0,-2) node[below] {$m$} -- +(0,1);

% EDGE LINES
\draw [line width=0.5pt, dotted] (\ox,\oy) +(-4,-2) node[below] {$x$} -- +(-4,1);
\draw [line width=0.5pt, dotted] (\ox,\oy) +(4,-2) node[below] {$x$} -- +(4,1);

% POLICY LINES
%\draw [line width=0.5pt, orange] (\ox,\oy) ++(-4,0)
% +(-0.2,-1) -- +(-0.2,1)
% +(0.2,-1) -- +(0.2,1);
%\draw [line width=0.5pt, orange] (\ox,\oy) ++(4,0)
% +(-0.1,-1) -- +(-0.1,1)
% +(0.2,-1) -- +(0.2,1);
% Function: policy line
% #1 : x
% #2 : x1 (relative to x)
% #3 : x2 (relative to x)
\newcommand{\policylines}[3]{%
\draw [line width=0.5pt, orange] (\ox,\oy) ++(#1,0)
+(#2,-1) -- +(#2,1)
+(#3,-1) -- +(#3,1)%
}
\policylines{-4}{-0.3}{0.3}; % 1/2 - Halfs rule
\policylines{4}{-0.1}{0.2}; % 1/3 - Thirds rule

% LINES
%\newcommand{\drawline}[2][violet]{%
% \draw [line width=0.5pt, color={#1}] (\ox,\oy)
% +(#2,-1) -- +(#2,1)%
%}
%\drawline[orange]{3};
%\newcommand{\drawline}[2][violet]{%
% \draw [line width=0.5pt, {#1}] (\ox,\oy)
\newcommand{\drawline}[2][line width=0.5pt, color=black]{%
\draw [{#1}] (\ox,\oy)
+(#2,-1) -- +(#2,1)%
}
%\drawline[orange, dotted]{3};
%\drawline{2.5};
%
%\draw [line width=0.5pt, violet] (\ox,\oy) ++(-3.7,-1)
%% ++(0,0) +(0,2)
% ++(1.2,0) -- +(0,2)
% ++(2.4,0) -- +(0,2)
%;


% First, produce a list of lines coordinates
% Then, use the list to draw the lines and draw annotations
% https://tex.stackexchange.com/questions/662928/is-this-the-right-way-to-understand-let-def-edef-gdef-xdef-newcommand-ren
% edef daclare a var, performing expansion
% xdef declare a global edef var
\xdef\lines{}
% TODO define as func with args { x, d_init, d, direction }
\foreach \n in {1,...,2} {
\edef\tmp{\lines,\n}
\xdef\lines{\tmp}
}

%%%% #1 : output var
%%%% #2 : n
%%%% #3 : x
%%%% #4 : d
%%%% #5 : d_init
%%%% #6 : lambda
%%%% #7 : direction
%%%\newcommand{\createlines}[6] {%
%%% % ##1 : n
%%% \newcommand{\calculate}[1] {%
%%%% \fpeval{#3 + ##1}%
%%% \fpeval{(#3 + #5) + (#4 * (#6 ^ ##1))}%
%%% }
%%% % ##1 : s
%%% % ##2 : d
%%% %% ##3 : n
%%% \newcommand{\calculates}[2] {%
%%%% \fpeval{#3 + ##1}%
%%% \fpeval{##1 + (##2 * #6)}%
%%% }
%%% \edef\currents{\fpeval{#3 + #5}}
%%% \edef\currentd{#4}
%%% \expandafter\xdef\csname #1\endcsname{}
%%%
%%% \foreach \n in {1,...,#2} {%
%%% \edef\currentd{\fpeval{\currentd * #6}}
%%% \edef\currents{\fpeval{\currents + \currentd}}
%%% \ifnum \n = 1%
%%%% \edef\tooutput{\calculate{\n}}%
%%% \edef\tooutput{\currents}%
%%%% \edef\tooutput{\calculates{\currents}{\currentd}}%
%%% \else%
%%%% \edef\tooutput{\csname #1\endcsname,\calculate{\n}}%
%%% \edef\tooutput{\csname #1\endcsname,\currents}%
%%%% \edef\tooutput{\csname #1\endcsname,\calculate{\n}}%
%%% \fi%
%%% \expandafter\xdef\csname #1\endcsname{\tooutput}%
%%% }%
%%%}

% #1 : output var
% #2 : n
% #3 : x
% #4 : d
% #5 : d_init
% #6 : lambda
% #7 : direction (+ | -)
\newcommand{\createlines}[7] {%
\tikzmath{
real \d, \s;
\d = #4;
\s = #3 #7 #5;
let \ret =;
for \i in {1,...,#2} {
\d = \d * #6;
\s = \s #7 \d;
if \i == 1
then { \ret = \s; }
else { \ret = "\ret,\s"; };
};
}
\expandafter\xdef\csname #1\endcsname{\ret}
}

%\createlines{linus}{3}{-4}
%\createlines{linus}{3}{-4}{0.6}{0.3}{2}
\createlines{lines}{7}{-4}{0.6}{0.3}{1.1}{+}

\edef\orig{\fpeval{-4+0.3}}

\foreach \n [expand list=true, count=\i] in {\lines} {
\drawline[green]{\n};
% \draw [line width=0.5pt, red] (\ox,\oy)
% ++(\n,-1) -- +(0,2) node[above] {\n};

% \draw [line width=0.5pt] (\ox,\oy) ++(-4,0) ++(0.3,0)
\draw [line width=0.5pt] (\ox,\oy) ++(\orig,0)
++(0,1) -- +(0,0.5);
\ifnum \i = 4
\draw [line width=0.5pt] (\ox,\oy)
++(\n,1) -- +(0,0.5);
\draw [line width=0.5pt] (\ox,\oy) ++(0,1.5)
+(\orig,0)
.. controls +(0,0.3) and +(0,0.3) ..
+(\n,0)
+(\fpeval{(\orig+\n)/2},0.2) node[above] {$z$}
+(\fpeval{(\orig+\n)/2},0.4) node[above] {$lz=\i$};
\fi
}

\edef\dmax{1}

\foreach \n [
expand list=true,
count=\i,
remember=\n as \lastn (initially \fpeval{-4+0.3})
] in {\lines} {
\draw [line width=0.5pt] (\ox,\oy) ++(0,1)
+(\lastn,0) .. controls +(0,0.2) and +(0,0.2) .. +(\n,0)
+(\fpeval{(\lastn+\n)/2},0.2) node[above] {$d\cdot\lambda$$^\i$};

\pgfmathparse{\dmax < \fpeval{abs(\lastn-\n)}}
\ifnum \pgfmathresult>0
\draw [line width=0.5pt] (\ox,\oy) ++(0,1)
++(\lastn,0) .. controls +(0,-0.2) and +(0,-0.2) .. +(\dmax,0)
+(\fpeval{(\dmax)/2},-0.2) node[below] {$d_{max}$};
\fi
}



% ANNOTATIONS
\draw [line width=0.5pt] (\ox,\oy) ++(-4,1)
+(-0.3,0) .. controls +(0,0.2) and +(0,0.2) .. +(0.3,0)
+(0,0.2) node[above] {$d$};

\draw [line width=0.5pt] (\ox,\oy) ++(-4,-1)
+(0,0) .. controls +(0,-0.1) and +(0,-0.1) .. +(0.3,0)
+(0.25,-0.1) node[below] {$d_{init}$};

\draw [line width=0.5pt] (\ox,\oy) ++(0,-1)
+(-3.7,0) .. controls +(0,-0.2) and +(0,-0.2) .. +(0,0)
+(-2,-0.2) node[below] {$s$};

%\draw [line width=0.5pt, yellow] (\ox,\oy) ++(0,-1)
% +(-3.7,0) to [bend right=30] +(0,0)
% +(-2,-0.2) node[below] {s};

\draw [line width=0.5pt] (\ox,\oy) ++(0,-1.5)
+(-4,0) .. controls +(0,-0.2) and +(0,-0.2) .. +(0,0)
+(-2,-0.2) node[below] {$h$};


\end{tikzpicture}
\end{document}
Loading