TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There are many packages which allow to type-set algorithms. I'm wondering whether there is a ready-to-use solution which allows to type-set computational problems?

I mean an environment which would include the name, input and output of a problem, and which would format it in a neat way.

share|improve this question
Can you point to some examples? – egreg Jan 13 '12 at 12:04
I have in mind something along the lines of what can be seen in the book "The Nature of Computation" by Cristopher Moore and Stephan Mertens. A centered frame with the name of the problem in the upper left corner, below input and description. But any esthetically pleasing solution would be fine. – Łukasz Grabowski Jan 13 '12 at 12:42
@ŁukaszGrabowski It would be easier if you could present a concrete example. Got a photo or screenshot? – N.N. Jan 13 '12 at 13:37
Do any of the packages mentioned in the algorithms tag wiki work for you? – Seamus Jan 13 '12 at 14:00
Searching for input+output in this book at Google Books returns several result which are pretty similar to rdhs' answer. E.g. this one: i.stack.imgur.com/IeTBz.png Probably this was what OP wanted. – Martin Jan 13 '12 at 17:43

If you don't need the problem to break pages, it seems pretty simple to hack something together using \fbox and a hanging indent:


    {\centering\scshape #1\par}%

\begin{problem}{Two-Player SAT}
    Input: A SAT formula $\phi(x_1,\dots,x_n)$

    Question: Two players, the Prover and the Skeptic, take turns setting the $x_i$.
    The Prover sets $x_1$, then the Skeptic sets $x_2$, and so on.
    After all the variables are set, the Prover wins if $\phi$ is true,
        and the Skeptic wins if $\phi$ is false.
    Does the Prover have a winning strategy?



If problems must break pages, look into using mdframed.

share|improve this answer
I'd prefer if a solution took care of page-breaks. I would think someone had to have this problem earlier, and there would be a ready-to-use package with no need for me to go into relatively low-level tex. But thx anyway (would up-vote but not enough reputation :-) – Łukasz Grabowski Jan 13 '12 at 22:20
@ŁukaszGrabowski how do you want page breaks "taken care of"? Do you want the box to break and then continue on the next page? Or do you want the whole box to move onto a page where there is enough room? – Seamus Jan 14 '12 at 14:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.