Table() formatting and 'adaptive' latex

24 views
Skip to first unread message

samuel...@gmail.com

unread,
Feb 4, 2025, 10:54:19 AM2/4/25
to Numbas Users
Hi, its been a while...

I'm using the table() function in my variables for use in my advice section, it'd be nice to have the formatting that was added to tables in the main sections (eg. thin borders and row shading).

I was trying to create a set of fractions for display using latex. The numerators and denominators coming from two lists of the same but varying length. Avoiding that exact problem, for the sake of clarity, is it possible to display a set of fractions such as:

1/denominators[0] + 1/denominators[1] + 1/denominators[2]

I need to accommodate a list of denominators of varying length.

I've tried various approaches to this and not succeeded. This is what eventually took me to using a table.

Thanks for your time
Sam

Ben Brawn

unread,
Feb 4, 2025, 5:18:02 PM2/4/25
to Numbas Users

I asked a friend and colleague because I know I have struggled with this before.

Here is an example https://numbas.mathcentre.ac.uk/question/share/view/379f7768-dd34-4a58-9d68-758f9e48695c 

You should be able to copy that and see what the variables are but regardless here is the run-down

  • define length as random(2..4)
    • (this is just a way to choose the randomise the number of terms in the sum)
  • define fraclist as [expression('1/x'), expression('a/b'), expression('3/10'), expression('2/(w+3)')][0..length]
    • ( Some expressions in a list, reduced to the random length )
  • define sumlist as expression(join(fraclist,'+'))
    • ( joining the frac list with plus signs and then making it an expression)
  • Then in a question part write $\simplify[!collectnumbers]{{sumlist}}$
  • refresh to see the length change

samuel...@gmail.com

unread,
Feb 5, 2025, 6:22:02 AM2/5/25
to Numbas Users
Thanks, the use of 'expressions' is helpful, it'll take a while for me to fully get to grips with what I'm trying to achieve.

Regarding the table formatting, it may actually be helpful to be able to switch the formatting on and off. I can imagine situations where table() might be used to display information where table shading etc. may not be desirable.

Cheers
Sam

Christian Lawson-Perfect

unread,
Feb 20, 2025, 7:30:54 AM2/20/25
to numbas...@googlegroups.com
You could use the CSS preamble to change how tables are displayed.

Can you give me an example question where there's a table with shading and borders? Are you talking about the grid for "match choices with answers" parts?

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/numbas-users/885a2e00-ca63-4b6d-8092-cb9390276eb9n%40googlegroups.com.

samuel...@gmail.com

unread,
Feb 24, 2025, 10:26:00 AM2/24/25
to Numbas Users
Thanks, I've started looking into using CSS and have made some progress. 

I did mean the grid for   "match choices with answers" parts, my memory let me down slightly!

Reply all
Reply to author
Forward
0 new messages