4

closely related to How to implement (low-level) arrays in TeX . What is the recommended package that provides a simple abstraction of the hash feature that is in latex, at least for small-scale needs. Think

\makeatletter
\AtBeginDocument{\hashrestore}
\newcommand{\hashinsert}[2]{\expandafter\def\csname #1\endcsname{#2}}
\newcommand{\hashget}[1]{\csname #1\endcsname}
\AtEndDocument{\hashsave}
\newcommand{\hashsave}{ ... write to file ... }
\newcommand{\hashretrieve}{ ... load from file ... }
\makeatother

It's just one global hash. This is essentially the same functionality that labels and refs provide through the .aux files. I know I have hacked around this problem a few times before, but the last times was years ago, and I can't recall how. I didn't abstract it, either. Grrr... Moreover, there may be newer packages that satisfy this need better. If no one answers this, I will look through my old tex hacks (comp.text.tex) to see what my most recent solution to this issue was. It's common enough a need to warrant a dedicated tex.stackexchange post.

I will want to use this, e.g., to define

\usepackage{hash}
\newcommand{\mycaption}[2]{\caption{#2}\label{#1}\hashinsert{#1}{#2}}
\newcommand{\myinshere}[1]{\begin{center} Insert Table \ref{#1}: \hashget{#1} \end{center}}

and in my document

...
\myinshere{tbl:1}
...

\begin{table} \mycaption{tbl:1}{Table 1} \end{table}
ivo Welch
  • 3,766
  • Looks as if you want to use the endfloat package with the markers option. – Ulrike Fischer Mar 20 '15 at 09:29
  • @Werner Or in the caption. –  Mar 20 '15 at 10:35
  • sorry about the label caption misorder. I was just trying to sketch the application. I also edited the title. – ivo Welch Mar 20 '15 at 16:07
  • ulrike+sean: endfloat with marker is a similar application to my usage illustration, but I want myinshere to print the caption text itself in the text to remind the reader what the table is about. this is what I need the hash (dictionary) for, in the first place. expl3 seem to be guidelines to programming and interface3 is very deep. This goes way deeper than what I can deal with. – ivo Welch Mar 20 '15 at 16:15