Skip to content

Commit

Permalink
Merge pull request #863 from Alex-Jordan/pg.sty
Browse files Browse the repository at this point in the history
Add a pg.sty file.
  • Loading branch information
pstaabp authored Jun 28, 2023
2 parents 87258d3 + acdc033 commit fe00e71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions assets/tex/pg.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pg}[2023/06/26 version 2.18]

\newcommand{\answerRule}[2][]{\raisebox{-3pt}{\parbox[t]{#2ex}{\hrulefill}}}

11 changes: 7 additions & 4 deletions macros/core/PGbasicmacros.pl
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ sub NAMED_ANS_RULE {
$tcol = $tcol < 40 ? $tcol : 40; ## get min

MODES(
TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
TeX => "{\\answerRule[$name]{$tcol}}",
Latex2HTML => qq!\\begin{rawhtml}<input type=text size=$col name="$name" value="">\\end{rawhtml}!,

# Note: codeshard is used in the css to identify input elements that come from pg
Expand Down Expand Up @@ -360,7 +360,7 @@ sub NAMED_HIDDEN_ANS_RULE {
$tcol = $tcol < 40 ? $tcol : 40; ## get min

MODES(
TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
TeX => "{\\answerRule[$name]{$tcol}}",
Latex2HTML => qq!\\begin{rawhtml}<input type=text name="$name" value="">\\end{rawhtml}!,
HTML => qq!<input type=hidden name="$name" id="$name" value="$answer_value">!
. qq!<input type=hidden name="previous_$name" id="previous_$name" value="$answer_value">!,
Expand Down Expand Up @@ -413,7 +413,7 @@ sub NAMED_ANS_RULE_EXTENSION {
my $tcol = $col / 2 > 3 ? $col / 2 : 3; ## get max
$tcol = $tcol < 40 ? $tcol : 40; ## get min
MODES(
TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
TeX => "{\\answerRule[$name]{$tcol}}",
Latex2HTML =>
qq!\\begin{rawhtml}\n<input type=text size=$col name="$name" id="$name" value="">\n\\end{rawhtml}\n!,
HTML => qq!<input type=text class="codeshard" size=$col name="$name" id="$name" aria-label="$label" !
Expand Down Expand Up @@ -1075,8 +1075,11 @@ sub NAMED_ANS_ARRAY_EXTENSION {
}
$answer_value = encode_pg_and_html($answer_value);

my $tcol = $col / 2 > 3 ? $col / 2 : 3; ## get max
$tcol = $tcol < 40 ? $tcol : 40; ## get min

MODES(
TeX => "\\mbox{\\parbox[t]{10pt}{\\hrulefill}}\\hrulefill\\quad ",
TeX => "{\\answerRule[$name]{$tcol}}",
Latex2HTML =>
qq!\\begin{rawhtml}\n<input type=text size=$col name="$name" id="$name" value="">\n\\end{rawhtml}\n!,
HTML => qq!<input type=text size=$col name="$name" id="$name" class="codeshard" aria-label="$label" !
Expand Down

0 comments on commit fe00e71

Please sign in to comment.