Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorize \ShowTags and add linebreak after #101

Open
thorstengrothe opened this issue Feb 15, 2019 · 4 comments
Open

Colorize \ShowTags and add linebreak after #101

thorstengrothe opened this issue Feb 15, 2019 · 4 comments
Labels
Feature request Request new functionalities and features new feature New accepted feature

Comments

@thorstengrothe
Copy link

\ShowTags shows the tags in the same line as the exercise text:

bildschirmfoto_2019-02-15_17-51-52

It would be nice if one can colourize the text with \textcolor{green}{tags} and if the tags are shown before the exercise text:

Tags: Gesundheitswesen (linebreak after tags)
Anne möchte die Struktur....

Is this possible?

@Strauman
Copy link
Owner

Why yes, yes it is. I’ll get back to you :)

@Strauman Strauman added Feature request Request new functionalities and features new feature New accepted feature labels Feb 15, 2019
@Strauman
Copy link
Owner

As it turns out, fixing it is not as easy as I thought.
However, let's make a workaround:
The macro containing the printing for the tags is \exb@printCurrentTags, so the first step would be to disable that. Secondly, the macro holding tags for a given exercise is \exb@currentTags, so we could just use a hook so you can choose where to put the tag. E.g.

\makeatletter
% Disable printing
\gdef\exb@printCurrentTags{}
% Print instead with green color.
\At\BeginPartproblem{%
Tags: {\color{green}\exb@currentTags}
}
\makeatother

At the next release (prerelease or experimental) you should also be able to use a new if to support the \ShowTags command. Namely \ifexb@showtags

@thorstengrothe
Copy link
Author

Thanks for the the workaround. At the moment I busy with #103. I will test later.

@thorstengrothe
Copy link
Author

With exercisebank-0.2.3b127-experimental and a bit modified code

\makeatletter
% Disable printing
\gdef\exb@printCurrentTags{}
% Print instead with green color.
\At\BeginPartproblem{%
\textbf{Tags:} {\colorbox{yellow}{\exb@currentTags}\par\smallskip}
}
\makeatother

it looks like this

tags

Until now the only issue is the first line is a bit more indented, I guess because of the points definition:

% Function to set stuff in right margin
% =======================================
\makeatletter
\setlength\parindent{0pt}
\newbox{\rmarbox}
\newbox{\tmp@rmarbox}
\newcommand\setrightmargin[1]{%
  % Calculate how far to move the box right to the margin
  \edef\mdwid{\the\dimexpr\textwidth+\marginparsep}%
  % Get the total height of the content
  \setbox\tmp@rmarbox=\hbox{#1}%
  \edef\totalrmarboxHT{\the\dimexpr-\ht\tmp@rmarbox-\dp\tmp@rmarbox}%
  % Make a new box with the height of content.
  % The box has to be moved up (due to \vadjust{}?)
  \setbox\rmarbox=\vbox{\kern\totalrmarboxHT\box\tmp@rmarbox}%
  \vadjust{\moveright\mdwid\box\rmarbox}%
}
\makeatother

% Setup the points
% ==================

\makeatletter
\At\AfterPPHeader{%
  \ifnum\exb@currentPoints=\z@\else%
  \setrightmargin{\rule{1cm}{.5pt}\centering{}~\exb@currentPoints~P.}%
  \fi\ignorespaces%
}
\exercisebanksetup{%
  current points style={}}
\makeatother

The rest is very good to read and useful for daily work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Request new functionalities and features new feature New accepted feature
Projects
None yet
Development

No branches or pull requests

2 participants