tikzposter \block にコード リストを配置するにはどうすればよいですか?

tikzposter \block にコード リストを配置するにはどうすればよいですか?

ポスターにコードリストを載せようとしていますが、次のエラーが発生します。

TeX の容量を超えました。申し訳ありません [入力スタック サイズ = 5000]

何が間違っているのでしょうか?

\documentclass[portrait, a0paper, 25pt]{tikzposter}
\title{title}
\author{}
\institute{}
\usepackage{color}
\definecolor{bluekeywords}{rgb}{0.13,0.13,1}
\definecolor{greencomments}{rgb}{0,0.5,0}
\definecolor{redstrings}{rgb}{0.9,0,0}
\usepackage{listings}
\lstset{language=[Sharp]C,
showspaces=false,
showtabs=false,
breaklines=true,
showstringspaces=false,
breakatwhitespace=true,
escapeinside={(*@}{@*)},
commentstyle=\color{greencomments},
keywordstyle=\color{bluekeywords}\bfseries,
stringstyle=\color{redstrings},
basicstyle=\ttfamily
}
\begin{document}
\maketitle
\block{Block title}{
\begin{lstlisting}
%some code
\end{lstlisting}
}
\end{document}
\endinput

答え1

いや...コードフォーマット...フォーマット...何でも...私は...死んでしまう...

lstlistingさらに深刻なのは、環境の内容が逐語的につまり、コマンドの引数内にそのような環境を含めることはできません (\blockここでは )。

一般的な回避策は、環境内にリストを埋め込むのではなく、外部ファイル(filecontentsパッケージの有無にかかわらず)にリストを記述し、コマンドで挿入することです。\lstinputlistinglstlisting

ここに画像の説明を入力してください

\documentclass[portrait, a0paper, 25pt]{tikzposter}

\title{title}
\author{}
\institute{}

\usepackage{color}
\definecolor{bluekeywords} {rgb}{0.13, 0.13, 1}
\definecolor{greencomments}{rgb}{0   , 0.5 , 0}
\definecolor{redstrings}   {rgb}{0.9 , 0,    0}

\usepackage{listings}
\lstset{
  language          = [Sharp]C,
  showspaces        = false,
  showtabs          = false,
  breaklines        = true,
  showstringspaces  = false,
  breakatwhitespace = true,
  escapeinside      = {(*@}{@*)},
  commentstyle      = \color{greencomments},
  keywordstyle      = \color{bluekeywords}\bfseries,
  stringstyle       = \color{redstrings},
  basicstyle        = \ttfamily,
}

% -----
% the following writes to an external file called 'foo.hs'
\usepackage{filecontents}
\begin{filecontents*}{foo.hs}
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
\end{filecontents*}
% -----

\begin{document}
\maketitle
\block{Block title}{%
  \lstinputlisting{foo.hs}
}
\end{document}

関連情報