diff options
-rw-r--r-- | example.tex | 4 | ||||
-rw-r--r-- | projdoc.cls | 1 | ||||
-rw-r--r-- | readme.md | 6 | ||||
-rw-r--r-- | requirements.tex | 1 | ||||
-rwxr-xr-x | scripts/reqs2tex.py | 13 |
5 files changed, 14 insertions, 11 deletions
diff --git a/example.tex b/example.tex index ee1377a..e0d21c0 100644 --- a/example.tex +++ b/example.tex @@ -3,7 +3,7 @@ % with the [draft] option. this replaces all images with placeholders. \input{meta.tex} -\input{reqs.aux} +\externaldocument{reqs}[./requirements.pdf] \title{Example Document} @@ -174,7 +174,7 @@ the glossary that is automatically printed after \codeinline{\end{document}}. \subsubsection{Requirements} Requirements are referenced like \codeinline{\label}s: -e.g.~\cref{req:audio:handle:id,req:audio:async-api:id}. +e.g.~\cref{req:audio:handle,req:audio:async-api}. \end{document} diff --git a/projdoc.cls b/projdoc.cls index c11fe61..8a592e3 100644 --- a/projdoc.cls +++ b/projdoc.cls @@ -40,6 +40,7 @@ \RequirePackage{tabularx} \RequirePackage{booktabs} \RequirePackage{needspace} +\RequirePackage{xr-hyper} \RequirePackage{hyperref} \RequirePackage{microtype} \RequirePackage{xcolor} @@ -18,6 +18,12 @@ A `latexmkrc` file is provided for copmilation with latexmk. The documents should also compile under [Visual Studio Code][vscode] using the [LaTeX Workshop extension][latexworkshop], as well as [VimTeX][vimtex]. +## TODO + +- Requirement cross-references are broken (they print both the label and the + path to the other document, should be label only). Interesting: + `\creflabelformat` and `\@templabel` (inside #2 of `\creflabelformat`). + [vscode]: https://code.visualstudio.com [latexworkshop]: https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop [vimtex]: https://github.com/lervag/vimtex diff --git a/requirements.tex b/requirements.tex index 39e5831..1b51220 100644 --- a/requirements.tex +++ b/requirements.tex @@ -6,6 +6,5 @@ \begin{document} - \end{document} diff --git a/scripts/reqs2tex.py b/scripts/reqs2tex.py index c5ab3dd..667eeb6 100755 --- a/scripts/reqs2tex.py +++ b/scripts/reqs2tex.py @@ -69,18 +69,15 @@ def convert(data): return reqs def req2aux(req): - # TODO: this is a dead-end solution, newlabel only works for in-document anchors, not external links + ref = tex.label2ref(req['label']) out = [ - tex.scmd('newlabel', f"req:{req['label']}:id", tex.group(req['id'], req['id'], '', './requirements.pdf', '')), - tex.scmd('newlabel', f"req:{req['label']}:id@cref", tex.group(f"[requirement][][]{req['id']}", '')), + tex.cmd('newlabel', f"{ref}", tex.group(req['id'], req['id'], 'ggg', 'hhh', 'iii')), + tex.cmd('newlabel', f"{ref}@cref", tex.group(f"[requirement][aaa][bbb]{req['id']}", '[ccc][ddd][eee]fff')), ] - return "\n".join([tex.auxout(line) for line in out]) + return "\n".join(out) def fmt_aux(data): - out = "" - out += tex.cmd('makeatletter') - out += "\n".join([req2aux(req) for req in data]) - out += tex.cmd('makeatother') + out = "\n".join([req2aux(req) for req in data]) return out def fmt_tex(data): |