Estou tentando colocar uma listagem de código no meu pôster, mas recebo o seguinte erro:
Capacidade do TeX excedida, desculpe [tamanho da pilha de entrada = 5000]
O que estou fazendo de errado?
\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
Responder1
Não... formato de código-... formatação... tanto faz..então...nunca... eu vou... morrer...
Mais seriamente, o problema é que o conteúdo do lstlisting
ambiente é tratadoliteralmente, o que significa que você não pode ter tal ambiente dentro do argumento de um comando ( \block
, aqui).
Uma solução comum é escrever a listagem em um arquivo externo (com ou sem o filecontents
pacote) e inseri-la com o \lstinputlisting
comando, em vez de incorporar a listagem dentro de um lstlisting
ambiente.
\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}