TransWikia.com

Align all marks/points to the right in exam class

TeX - LaTeX Asked on July 26, 2021

I want to learn how to align marks (to the right) and start the question always on a new line.

My MWE:

documentclass[a4paper,12pt]{exam}
usepackage{amsmath}
pointsinrightmargin

renewcommandchoicelabel{(Alph{choice})} 
renewcommand{choiceshook}{%
    setlength{leftmargin}{25mm}% 
    setlength{labelwidth}{labelsep }%
    }

renewcommand{questionlabel}{ textbf{Question thequestion}:}

begin{document}
begin{questions}
    
    question[1]  Start this line on a new line and align the marks with the rest of the paper.
    begin{choices} choice 1 choice 2 choice 2 choice 3 end{choices}
    
    question[2]  Drop and align this one too.
    begin{choices} choice 6 choice 3 choice 2 choice 0 end{choices}
    
    question[3]
    Drop and align this sentence too!
    
    question Drop and align this sentence one too!
    
    begin{parts} % Keep this part as it is.
        part[4] Keep as it is.
        part[5] Keep as it is.
        part
        Consider this and that:
        begin{subparts}
            subpart[6] This one is aligned with the parts.
            subpart[7] So is this one.
        end{subparts}
    end{parts}
end{questions}
end{document}

I tried to use

setlength{rightpointsmargin}{15mm}

But it simply shifts all marks, but the one I’m interested in are the ones that have gone over the page.

Ideally, this is what I would like to always happen (regardless if I modify the question/parts/choice labels/shook).

Expected result

EDIT: UPDATED CODE

documentclass[a4paper,12pt]{exam}
usepackage{amsmath}
usepackage[showframe=true]{geometry}
pointsinrightmargin
pointname{}
pointformat{textbf{thepoints}}

qformat{{textbf{Question thequestion}}hfilltextbf{thepoints}hspace{-1.5cm}}

renewcommandchoicelabel{(Alph{choice})} 
renewcommand{choiceshook}{%
    setlength{leftmargin}{25mm}% 
    setlength{labelwidth}{labelsep}%
    }


begin{document}
begin{questions}
    
    question[1]  Start this line on a new line and align the marks with the rest of the paper.
    begin{choices} choice 1 choice 2 choice 2 choice 3 end{choices}
    
    question[2]  Drop and align this one too.
    begin{choices} choice 6 choice 3 choice 2 choice 0 end{choices}
    
    question[3]
    Drop and align this sentence too!
    
    question Drop and align this sentence one too!
    
    begin{parts} % Keep this part as it is.
        part[4] Keep as it is.
        part[5] Keep as it is.
        part
        Consider this and that:
        begin{subparts}
            subpart[6] This one is aligned with the parts.
            subpart[7] So is this one.
        end{subparts}
    end{parts}
end{questions}
end{document}

One Answer

An ugly patch:

documentclass[a4paper,12pt]{exam}
usepackage{amsmath}
usepackage[showframe=true]{geometry}
pointsinrightmargin
pointname{}
pointformat{textbf{thepoints}}

qformat{{textbf{Question thequestion}}hfill%
rlap{hspace*{14.5mm}textbf{thepoints}}
}

renewcommandchoicelabel{(Alph{choice})} 
renewcommand{choiceshook}{%
    setlength{leftmargin}{25mm}% 
    setlength{labelwidth}{labelsep}%
    }


begin{document}
begin{questions}
    
    question[1]  Start this line on a new line and align the marks with the rest of the paper.
    begin{choices} choice 1 choice 2 choice 2 choice 3 end{choices}
    
    question[2]  Drop and align this one too.
    begin{choices} choice 6 choice 3 choice 2 choice 0 end{choices}
    
    question[3]
    Drop and align this sentence too!
    
    question Drop and align this sentence one too!
    
    begin{parts} % Keep this part as it is.
        part[4] Keep as it is.
        part[5] Keep as it is.
        part
        Consider this and that:
        begin{subparts}
            subpart[6] This one is aligned with the parts.
            subpart[7] So is this one.
        end{subparts}
    end{parts}
end{questions}
end{document}

Answered by Alan Xiang on July 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP