TransWikia.com

Creating a LaTeX Math Homework Template with Tables

TeX - LaTeX Asked on June 26, 2021

I am trying to make a simple math homework template (as a student) to answer questions from a book. So far it has gone alright but I have hit a roadblock:
I cant seem to get the tables right. Table problem

Fig. 1: A snippet from the pdfLaTeX-produced document which shows the problem.

begin{tabular*}{textwidth}{L@{extracolsep{fill}}CR}
        textbf{A} & textbf{B} & textbf{C} 
a & a & a 
end{tabular*}

The math columntypes.

newcommand{rtable}[2]{newcolumntype{#2}{>{$}#1<{$}}}
rtable{l}{L}   rtable{c}{C}   rtable{r}{R}

And im using this to create the L C R math versions of the regular l c r column types.
If you have better ways to do this without using tables or some more specific package please do let me know.


NOTE: If you yourself are also trying to do this I used this piece of code to match the math books numbering system; thanks to this piece of code I do not need to manually set the numbers every time

renewcommand{thesubsection}{arabic{section}.Alph{subsection}}
renewcommand{thesubsubsection}{arabic{section}.Alph{subsection}.arabic{subsubsection}}

And this to set the starting point because often I will seperate it to different .pdf files

setcounter{section}{0}
section{Mengi}
setcounter{subsection}{0}
subsection{Stök og Venn-myndir}
setcounter{subsubsection}{0}
subsubsection{Test}

enter image description here

Fig 2: Image of almost perfect outcome

Here is another try where I used simple minipages with 0.333textwidth and they work very well with flushleft, centerline, and flushright respectively.

HOWEVER: The problem with this is that, you might notice, its not using a math environment, and I was never able to get math-mode inside of the minipages, the text was really weird, huge margins and all kinds of really weird stuff so I gave up. This image should illustrate what the perfect outcome should be (only the math mode is missing)

One Answer

So, I have managed to hack this together with the following code using tabularx:

newcommand{svar}[6]{begin{tabularx}{linewidth}{|x|C|x|}
        hline
        hspace{-1.9mm}textbf{#1} & $centerline{textbf{#3}} $ & rightline{textbf{#5}}
        hline
        #2$ & $#4$& rightline{$#6$} 
hlineend{tabularx}
}

The hline's (and corresponding |'s) are only for reference while im working on this. The big downside to this solution is that it does not allow for any kind of linebreaks which ideally I should be able to use when writing longer equations etc.

Any help would be immensely helpful, I never thought this would be a weeks long dreadful project. I am desperate at this point.

newcolumntype{C}{>{centeringarraybackslash}X}
newcommand{rtable}[2]{newcolumntype{#2}{>{$}#1<{$}}}
rtable{X}{x}

The redefined columns to allow for this hack.


This template work has been seriously draining my mental health, so I'm very sorry if I might answer in a passive-agressive tone.

Answered by user224041 on June 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