gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] LaTeX placeholder line template explained


From: Karsten Hilbert
Subject: [Gnumed-devel] LaTeX placeholder line template explained
Date: Fri, 17 Feb 2012 21:55:16 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Feb 17, 2012 at 04:57:54PM +0000, Vaibhav Banait wrote:

> When I use line template as below,
> \begin{enumerate}
> \item §<current_meds::line_template>::75 >§
> \end{enumerate} 
> I get output text ''line_template'' rather than any medication . Kindly help.

Aaah, I see.

So, the example I gave a few posts back wasn't clear enough :-)

For one thing you'll need to use the placeholder format:

        $<...>$

Then, the "line_template" thingy needs to be replaced by
something useful. GNUmed uses the string one uses as
template, does %(something)s string replacement on it, and
returns the result.

If one uses the "current_meds" placeholder and the template
is "line_template" then GNUmed will do:

for each current medication:
        formatted_medication = template % current_medication
return all formatted medications

So, if template is "line_template" then GNUmed will do

        "line_template" % current_medication

which will return "line_template" (because there's no
%s-style replacements in "line_template") - just like you
noticed.

Let's take something more useful as template:

        "substance: %(substance)s"

This will come to be:

        "substance: %(substance)s" % current_medication

which will then return:

        "substance: Metoprolol"
        "substance: HCT"

Now, since you don't know how many current_medications there
will be you cannot know how many "\item ..." to put inside:

        \begin{enumerate}
                \item $<current_meds::substance: %(substance)s::75>$
        \end{enumerate}

This is solved by putting the *complete* line template
(there, that's why I called it line_template !) inside the
placeholder:

        \begin{enumerate}
                $<current_meds::\item substance: %(substance)s::75>$
        \end{enumerate}

This would become:

        \begin{enumerate}
                \item substance: Metoprolol
                \item substance: HCT
        \end{enumerate}

Which will be in the PDF:

        1. substance: Metoprolol
        2. substance: HCT

Since the letter template is LaTeX the placeholder template
must produce valid LaTeX code. Had it been AbiWord or
LibreOffice then it would have needed to be AbiWord XML or
LibreOffice ODT code.

Starting from this knowledge one can get pretty fancy and do
nearly anything within the template. There's nooks and
crannies, and, yes, one needs to know some arcana but, you
know, it's all open source, partially documented, there's
example templates, and now it's also documented in the list
archives. I'm sure the User Manual Advanced Topics could
well use a paragraph or two on this ;-)

Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



reply via email to

[Prev in Thread] Current Thread [Next in Thread]