Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to get strings from an external program, as shown in this example:

\documentclass{article}
  \usepackage{fontspec}
  \usepackage{xunicode}
  \newcounter{verse}
  \stepcounter{verse}
  \immediate\write18{/home/rpinson/bas/tex/diatheke2tex "Jn 3:16" "FreMartin" "\roman{verse}" "\jobname.verses"}
  \begin{document}
  \input{\jobname.verses}
  \versei
\end{document}

Where diatheke2tex is:

#!/bin/bash

REF="$1"
VERSION="$2"
ID="$3"
FILE="$4"

echo "\\newcommand\\verse${ID}{%" >> $FILE

diatheke -o plain -b "$VERSION" -k "$REF" | \
  head -n -1 | \
  sed -e 's/^[^:]\+ [0-9:]\+://' >> $FILE

echo "}" >> $FILE

The \versei is kind of a hack, as it's not possible to use spaces and numbers in a macro name. Obviously, this is not a proper solution…

How can I build an associative array of some sort associating references (like Jn 3:16) to the result of the command (in this case Car Dieu a tant aimé le monde, qu'il a donné son Fils unique, afin que quiconque croit en lui ne périsse point, mais qu'il ait la vie éternelle.)?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Actually, spaces and numbers can be used in a macro name (csname), see an example of definition and usage of an associating reference below:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\expandafter\def\csname[Jn 3:16]\endcsname{Car Dieu a tant aimé le monde\dots}
\begin{document}
\csname[Jn 3:16]\endcsname
\end{document}
share|improve this answer
    
Great, thank you! –  ℝaphink Mar 26 '13 at 9:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.