1

I want to typeset physics solution like this:

example1

It's in Ukrainian, but the contents doesn't matter.

I want to have two columns:

  • In the left column there should be two cells: one with given values, the other with unknowns.
  • In the right column there is a solution.

There should be a line dividing this two columns. After given values there should be a horizontal line, dividing the unknowns.

Inside solution cell the user should be able to write formatted texts, have line breaks, centering of text, formulas, etc.

I've tried to make this with tables and multicols, but these attempts were unsuccessfull.

An example of my attempt:

\documentclass[12pt]{article}

\usepackage{amsmath}

\usepackage{tabularray}

\begin{document}
    \begin{table}
        \centering
        \begin{tblr}{
                width = \linewidth,
                colspec = {Q[273]Q[273]},
                cells = {t},
                cell{1}{2} = {r=2}{},
                vline{2} = {-}{},
                hline{2} = {1}{},
            }
            \textbf{Givens}:
            
            $V$
            
            $V_0$
            
            $p$
            
            $p_0$
            
            $T = const$
            
            &
            \begin{center}
                \textbf{Solution}
            \end{center}
            
            Lorem ipsum... We got this formula:
            \[p_0V = p_1(V_0 + V)\]
            
            And then we got this:
            \[p_1 = \dfrac{p_0V}{V_0 + V}\]
            
            ...
            
            \\
            $n\ =\ ?$
            &   
        \end{tblr}
    \end{table}
\end{document}

Still, looks far from ideal. And also it generates a lot of errors.

Image: my_attempt_1

6
  • Welcome. // It would be very helpful, if you'd show your unsuccessful attempt as code, perhaps with some simplifications, as long as you can demonstrate your problem: you seem to know what you are doing. Thank you // BTW: I can't read the problem-solution structure from your screenshot. That seems to be a collection of formulas on gases.
    – MS-SPO
    Apr 8 at 12:19
  • 1
    Hello. I've updated the question. I wanted to include an example in English, but haven't found one. Probably, the style of European or American solutions differs a lot in comparison to the style that is taught in post-USSR countries Apr 8 at 12:44
  • Thank you: Now I see the line with n was intended to be the question. Much better now.
    – MS-SPO
    Apr 8 at 12:53
  • So, "Solution, lore ipsum ..." : is that part relevant content of a kind of header, with other content on the rest of the page, OR do you just insert a block of text from the left into a constant textflow (Givens and question in this case) ?
    – MS-SPO
    Apr 8 at 13:13
  • The only thing I need in this teplate is 3 cells (2 on the left, 1 on the right). "Givens" and "Solution" header. And everything is just a content that is relative to the physics problem. In the example I provided: givens are cool, unknowns are okay but they are vertically centered (I want top-align), there is some vertical offset before "Solution" header, it should not be. And also, as I said, the example compiles with errors Apr 8 at 15:15

1 Answer 1

1

You can use the wrapfig package to place a tabular in the upper left corner of the document. The solution text will flow around using the full text area.

c

\documentclass{article}

\usepackage{wrapfig} % added <<<<<<<<<<<<<

\usepackage{amsmath}

\usepackage{lipsum}% dummy text <<<

%------------------------------------------
\begin{document}
    
    \setlength\parindent{0pt}
    %------------------------------------------
    \begin{wraptable}{l}{0pt} % left side, natural width \begin{wraptable}[number of text rows]{position}{width}
        \renewcommand{\arraystretch}{1.15} %optional
        \begin{tabular}{p{0.2\textwidth}|}  % wider rows
            \textbf{Givens}:\\          
            $V$\\       
            $V_0$\\     
            $p$\\       
            $p_0$\\     
            $T = const$\\ \hline    
            \rule{0pt}{1.5em} % this row higher
            $n\ =\ ?$
        \end{tabular}
    \end{wraptable}
    %------------------------------------------
        
    \hfill\textbf{Solution}\hfill
    \bigskip
    
    Lorem ipsum... We got this formula:
    \[p_0V = p_1(V_0 + V)\]
    
    And then we got this:
    \[p_1 = \dfrac{p_0V}{V_0 + V}\]     
    
    \lipsum[2] 

\end{document}

To keep the solution on the right side, use for example

\begin{wraptable}[46]{l}{0pt}

to lengthen the wraptable to the end of the text area.

d

This alternative solution uses the paracol package to write two columns.

x

\documentclass{article}

\usepackage{amsmath}

\usepackage{paracol}% added <<<<<<<<<

\usepackage{lipsum}% dummy text <<<  
    
\begin{document}
    \setlength{\columnseprule}{0.5pt}  % width of the vertical rule
    \columnratio{0.2} % column ratio
    \setlength{\columnsep}{20pt}  % column separation
    \setlength{\parindent}{0pt}
    
    \begin{paracol}{2}\sloppy   
        \renewcommand{\arraystretch}{1.2} %optional
        \begin{tabular}{p{0.2\textwidth}}   % wider rows
            \textbf{Givens}:\\          
            $V$\\       
            $V_0$\\ 
            $p$\\       
            $p_0$\\     
            $T = const$\\[-2ex] \rule{\dimexpr\columnwidth-\tabcolsep+0.5\columnsep}{0.5pt} 
            $n\ =\ ?$
        \end{tabular}
        
        \switchcolumn  % to right column

         \begin{center}
            \textbf{Solution}
        \end{center}
        
        Lorem ipsum... We got this formula:
        \[p_0V = p_1(V_0 + V)\]
        
        And then we got this:
        \[p_1 = \dfrac{p_0V}{V_0 + V}\]     
        
        \lipsum[2-6] 
    \end{paracol}
    
\end{document}
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .