On 10.06.2010, at 11:02, stephen's mailinglist account wrote:

>>> On 06/02/2010 10:59 AM, Rob Oakes wrote:
>>>> Dear LyX-Users,
>> 
>>>> I am in the process of creating a custom of modules for personal use
> 
>>>> p  and another for the creation of epigraphs).  For the epigraph
>>>> module to work correctly, it is important that I be able to use multiple
>>>> input arguments.  For example, the LaTeX code for the epigraph command
>>>> has the form \epigraph{Quotation}{Source}.
>> 
>>>> \epigraph{If a picture isn't worth a thousand words, the hell with
>>>> it.}{Ad Reinhardt}
>> 
>>>> Is anyone aware of a way to create an inset that could support this type
>>>> of macro?  I've looked through several of the examples shipped with LyX
>>>> and wasn't able to find a similar example.
>> 
>> The dinbrief.layout uses the following workaround in a similar case::
>> 
> I have created a module for epigraph using the style of workaround
> suggested by DINbrief
> 
> http://wiki.lyx.org/uploads/Modules/epigraph/epigraph.module
> 
> it uses 3 terms (text, source and typeset) because I wanted to make
> the source italic.
> 
> I would be interested in comments and feedback as to how to do this
> better/more elegantly

An alternative approach might be to exploit plain tex to delimit the arguments 
in a way that is opaque to LyX. Hence, from the viewpoint of LyX and LaTeX, we 
pass a single argument, which then is internally parsed to split it up to 
whatever you need. Minimal example (LaTeX):

\documentclass{minimal} 

\newcommand*{\epigraph}[1]{%
  \def\parsearg##1+##2+{\def\one{##1}\def\two{##2}\relax}
  \parsearg#1+
  \emph{\one} (\two)
}

\begin{document} 
 
  \epigraph{Das Leben ist des Lebens Ziel+unbekannt}

\end{document}

Note that \epigraph gets just one argument, which is then internally split into 
two. In the example I have used the plus symbol (+) as delimiter to split the 
arguments; the delimiter itself is not printed.  However, you might use 
whatever you want to delimit the arguments, even complex tokens:

\documentclass{minimal} 

\newcommand*{\epigraph}[1]{%
  \def\parsearg##1 QUOTE OF ##2\end{\def\one{##1}\def\two{##2}\relax}
  \parsearg#1\end
  \emph{\one} (\two)
}

\begin{document} 
 
  \epigraph{Das Leben ist des Lebens Ziel QUOTE OF unbekannt}

\end{document}

Some additional work is required if you want the second part to be optional, 
though this should be possible as well.

Daniel

Reply via email to