go(plot): streamline caption generation
All checks were successful
continuous-integration/drone/push Build is passing

* make sure to latex-escape captions (for correct line breaks)
* enable showing captions
* enable listing subfigure captions
* make sure latex lof (list of figures) picks up on subfigure captions
* clarify we need the subcaption package for subfigures, not subcaptions
This commit is contained in:
surtur 2022-07-19 19:23:39 +02:00
parent 333a5c4e48
commit 44cc400474
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
3 changed files with 9 additions and 4 deletions

@ -6,6 +6,7 @@ package algo
import (
"fmt"
"log"
"strings"
"time"
"git.dotya.ml/wanderer/math-optim/report"
@ -180,9 +181,9 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
picMean := report.NewPic()
meanTitle := "D: " + fmt.Sprint(s.Dimens) + ", G: " +
fmt.Sprint(s.Generations) + ", I: " + fmt.Sprint(s.Iterations)
// picMean.Caption = "D:~" + fmt.Sprint(s.Dimens) + ", G:~" +
// fmt.Sprint(s.Generations) + ", I:~" + fmt.Sprint(s.Iterations)
picMean.Caption = ""
// this is latex-rendered.
picMean.Caption = "Mean - " + strings.ReplaceAll(meanTitle, " ", "~")
// set pic file path (later used in tmpl generation)
pic.FilePath = filename

@ -15,6 +15,7 @@
% note: this accomodates 3 plots a row comfortably..should the requirements
% change, this would have to be reworked.
{\includesvg[scale=0.45]{ {{- printf "%s" $v.FilePath -}} }}
\caption{ {{- printf "\\scriptsize{%s}" $v.Caption -}} }
\end{subfigure}
\hfill
{{- end -}}
@ -22,9 +23,11 @@
\begin{subfigure}{0.30\textwidth}
\vspace{2em}
{\includesvg[scale=0.45]{ {{- printf "%s" $w.FilePath -}} }}
\caption{ {{- printf "\\scriptsize{%s}" $w.Caption -}} }
\end{subfigure}
\hfill
{{- end }}
\caption{ {{- printf "%s - %s" .Algo .Bench -}} }
\end{figure}
% vim: ft=gotexttmpl.tex ts=2 sts=2 sw=2 bs=2 expandtab

@ -16,7 +16,8 @@
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{hyperref}
\usepackage{subcaption} % for subcaption
\usepackage[list=true]{subcaption} % for subfigures
\setcounter{lofdepth}{2} % we want subfigures in the list of figures
\usepackage{sansmath}
\sansmath
\usepackage{svg}