How can I insert the following WinBugs code into LaTeX as a text format?
model
{
for(i in 1:nSUB)
{
s[i] ~ dnorm(0,tau.precision);
}
}
I tried \texttt{}
:
\texttt{model
\{ \par
for(i in 1:nSUB) \par
\{ \par
s[i] $\sim$ dnorm(0,tau.precision); \par
\} \par
\}
}
However, it gives a error message:
{model \{ ! Paragraph ended before \text@command was complete. ....
I tried \usepackage{listings}
, and used language R because there's no WinBugs language included.
\begin{lstlisting}[language=R]
model
{
for(i in 1:nSUB)
{
s[i] ~ dnorm(0,tau.precision);
}
}
\end{lstlisting}
There's no error message, but the text still looks very strange.
verbatim
environment is the simple approach.listings
(here) orminted
packages. Both of them have great documentation. Check this post for instance as a starting point. This will help you make your own language style.