1

I am making a list of problems for a contest that should look like this:

Problem 1. Some text 
5 points   As the text continues it stays aligned
           to this
           |<--
           |<--
            Invisible line
Problem 2. More text
1 point    also aligned

I want to use an enumerate-like environment, like

\newenvironment{questions}{
\begin{list}{ 
    \bfseries\upshape\arabic{qcounter}.
}{
    \renewcommand{\makelabel}[1]{%
\textbf{\refstepcounter{qcounter}\arabic{qcounter}##1.}}%
    \usecounter{qcounter}
    \setlength{\labelwidth}{2.5em}
    \setlength{\labelsep}{0.5em}
\setlength{\leftmargin}{\labelwidth+\labelsep}
        \setlength{\itemsep}{2pt}
        \setlength{\listparindent}{1em}
    \setlength{\parsep}{1pt}
    \setlength{\topsep}{6pt}
} 
}{    
    \end{list}
}

I have changed renewing of makelabel to

\renewcommand{\makelabel}[1]{%
\textbf{\refstepcounter{qcounter}Problem \arabic{qcounter}##1.}\\##1 points}

but it didn't work. I also tried putting it into minipage, but the text of the item looks strange after it.

I also want to give item to arguments: number of points and the ending or the word points, like point##2, because I write in russian and the ending of the word changes strongly, depending on the number.

Is there any option I can do such a list?

My code (LuaLaTeX):

\documentclass[10pt,landscape]{extarticle}
\usepackage[top=1cm, bottom=1cm, left=0.25in, right=0.25in]{geometry}
\pagestyle{empty}
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\usepackage{ragged2e}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{comment}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{wrapfig}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usepackage{skull}
\usepackage{faktor}
\usepackage{xfrac} 
\usepackage{enumitem}
\usepackage{lipsum}
%
\usepackage{multicol}
\usepackage{tabularx}
\setlength\tabcolsep{0pt}
\setlength{\columnsep}{1cm}
\setlength{\columnseprule}{0.4pt}
%
\usepackage[russian]{babel}
\usepackage{mathptmx}
\usepackage{polyglossia}    
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Times New Roman}
\newfontfamily\cyrillicfont{Times New Roman}
\usepackage{mathrsfs}   
\setmainlanguage{russian}


\newcounter{qcounter}
\newenvironment{questions}{
\begin{list}{ 
    \bfseries\upshape\arabic{qcounter}.
}{
    \renewcommand{\makelabel}[1]{%
\textbf{\refstepcounter{qcounter}\arabic{qcounter}##1.}}%
    \usecounter{qcounter}
    \setlength{\labelwidth}{2.5em}
    \setlength{\labelsep}{0.5em}
\setlength{\leftmargin}{\labelwidth+\labelsep}
        \setlength{\itemsep}{2pt}
        \setlength{\listparindent}{1em}
    \setlength{\parsep}{1pt}
    \setlength{\topsep}{6pt}
} 
}{    
    \end{list}
}

\begin{document}
\begin{questions}

\item[1] \lipsum[1]

\item[2] \lipsum[2]

\end{questions}
\end{document}
  • It think it would be simpler to do with a theorem-like structure. – Bernard Dec 26 '16 at 16:26
  • @Bernard, but what about alignment in that case? – Michael Fraiman Dec 26 '16 at 16:30
  • You can use the \theoremindentparameter (from ntheorem) and use the optional argument of a theorem environment for the second line. With a list and enumitem I don't see how to have an optional argument for \item in a simple way. – Bernard Dec 26 '16 at 16:37
  • There is also \hangindent, or \letskip and \llap{\makebox[\leftskip][l]{...}} – John Kormylo Dec 27 '16 at 4:23
1
\usepackage{calc}
\newcounter{qcounter}
% Item parameter is number of points.
% See The LaTeX Companion, Second Edition, page 150.
\newcommand{\questionlabel}[1]{%
  \refstepcounter{qcounter}\raisebox{0pt}[1ex][0pt]%
  {\makebox[\labelwidth][l]%
    {\parbox[t]{\labelwidth}%
      {\hspace{0pt}\textbf{Problem \arabic{qcounter}}\\#1 points}}}}

\newenvironment{questions}
{\begin{list}{}{\let\makelabel\questionlabel
    \setlength{\itemsep}{2pt}
    \setlength{\listparindent}{1em}
    \setlength{\parsep}{1pt}
    \setlength{\topsep}{6pt}
    \settowidth{\labelwidth}{\textbf{Problem 99}}%
    \setlength{\labelsep}{0.5em}%
    \setlength{\leftmargin}{\labelwidth+\labelsep}%
    \usecounter{qcounter}}
}
{    
    \end{list}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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