# [Tex/LaTex] Center a Listing on page

horizontal alignmentlistings

I am trying to center a listing horizontally within a page.

So far I have tried defining the following macro:

\lstnewenvironment{snippet}[1][]
{\centering \lstset{float=htpb,#1}}
{}


But it did not work.

I have read this question and answer, but I would prefer a solution that does not rely in figures or tables.

\lstnewenvironment{snippet}[1][]