2

Connsider the following code:

\documentclass{article}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{lipsum}
\begin{document}
\begin{lstlisting}[frame=tb,numbers=none,emph={quadrat},mathescape=true,literate={{≔}{$\coloneqq$}1}]
proc quadrat  =  (x: var Nat, a: Nat):  x:= a * a $\Box$
\end{lstlisting}
\lipsum[1]
\end{document}

In the output, the qed symbol is not at the right margin:

pdflatex output

How to move the QED symbol to the right margin without manually introducing \hspace{...} (which would need to be changed whethen the page dimensions change)?

Btw., ntheorem and amsthm are NO-GO, since they irrepairably conflict with my full, non-minimal setup (svmono + tons of other packages).

1 Answer 1

1

You can escape to latex with the option escapechar=[character]:

\documentclass{article}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{lipsum}
\begin{document}
\begin{lstlisting}[frame=tb,
                   numbers=none,
                   emph={quadrat},
                   mathescape=true,
                   escapechar=§,
                   literate={{≔}{$\coloneqq$}1}]
proc quadrat  =  (x: var Nat, a: Nat):  x:= a * a §\hfill$\Box$
\end{lstlisting}
\lipsum[1]
\end{document}

result

I used § as escape character, choose one to your liking, that is not used in the code. You can go back to normal code by using the escape character again. You can find more info in the documentation.

0

You must log in to answer this question.