Math & Science"problem" environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
manflower
Posts: 4
Joined: Sat Jan 30, 2010 7:42 pm

"problem" environment

Post by manflower »

Hello,

I tried looking around, but it is very hard because of google keywords confusing what I want semantically ("problem environment input output" etc.)

I want to create/use some existing environment which its output is as follows for example:

Problem 1.
Input: Graph G=(V,E)
Output: n, Number of cycles in graph

That's an example, of course.
It is similar to the header of the algorithm environment, only I want the Problem heading and not have an actual algorithm below that, just the problem definition. Any ideas?

Oh, and I want "input" and "output" to be in bold, if that matters a lot...

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

"problem" environment

Post by gmedina »

Hi,

it all depends on your particular needs. In the following example I defined a really basic new command (\myprob) that could give you some ideas:

Code: Select all

\documentclass{article}

% creation of a new counter
\newcounter{mycount}
% definition of the command
\newcommand\myprob[2]{%
  \stepcounter{mycount}
  \par\noindent Problem\ \themycount .\\
  {\bfseries Input}: #1\\
  {\bfseries Output}: #2\par
}
  
\begin{document}

\myprob{Graph $G=(V,E)$}{$n$, Number of cycles in graph}

\myprob{another input}{another output}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply