0

I want to have tikz-figures in a two-column document with a subfile structure but I am running in circles. When I throw in multicols I have two columns but no tikz-figures and when I throw out multicols I have figures but only 1 column. The top-level which I've called exercises.tex is where I pull in the subfiles. I have \usepackage{subfiles} as the last included package as recommended at https://www.overleaf.com/learn/latex/Multi-file_LaTeX_projects#The_subfiles_package I compile with either lualatex or pdflatex. Below is exercises.tex:

\documentclass{book}[twocolumn]
\usepackage{parskip}
\usepackage[bottom=1in]{geometry}
\usepackage{multicol}
\setlength{\columnsep}{0.9cm}
\usepackage{supertabular}
\usepackage[utf8]{inputenc}
%\usepackage{geometry}   % Setup for page and paper dimensions
\usepackage{wrapfig}
\usepackage{subfigure}
\usepackage{caption}
\captionsetup{
  font=small,
  labelfont=bf,
  tableposition=top
}
\usepackage[swedish]{babel}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black,
    pdfborder = {0 0 0}
}
\usepackage{verbatimbox}
\usepackage{graphicx}   
\usepackage{lipsum}  
\usepackage{amsmath}
\usepackage{listings} 
\usepackage{tikz}
\newcommand*\mycirc[1]{%
\begin{tikzpicture}[baseline={(0,-0.1)}]
\node[draw,circle,inner sep=1pt] {#1};
\end{tikzpicture}}
\newcommand*\textcircle[1]{\textcircled{\raisebox{0.14em}{#1}}}
\usepackage{ifthen}         
\mathchardef\mhyphen="2D
\usepackage{subfiles}
\begin{document}
%\begin{multicols}{2}

\subfile{5189b.tex}

%\end{multicols}
\end{document}

The subfile 5189b.tex looks like this:

\documentclass[./exercises.tex]{subfiles}
\begin{document}

\noindent\textbf{5.1-89}\hfill\break
\noindent En ideal gas genomlöper följande kretsprocess medurs:\hfil\par
\noindent\begin{tabular}{ l l  } 
1 $\rightarrow$ 2 & Uppvärmning under konstant volym\\
                  & från $t_1$ till $t_2$  \\ 
2 $\rightarrow$ 3 & Isentropisk expansion till $t_3$  \\ 
3 $\rightarrow$ 1 & Isoterm kompression till utgångs-\\
                  &punkten \\ 
\end{tabular}


Rita processen i $p$-$v$- och $T$-$s$-diagrammen. Beräkna processens termiska
verkningsgrad då $t_1=20^{\rm{o}}$C och $t_2=200^{\rm{o}}$C.

\bigskip


\begin{figure}[h]
\centering
%%%%%%%%%%%%%%%p-V-diagram
\subfigure[$p\mhyphen V$ diagram] 
{
\begin{tikzpicture}[ scale=.4,baseline={(0,0)}]
%\draw (0,0) grid (4,4);
% x-axis
\draw [thick,->] (0,0) -- (4,0) node[right]{$V$};
% y-axis
\draw [thick,->] (0,0) -- (0,4) node[above] {$p$};
% x-axis label
%\node at (-0.3,4){$p$};
% y-axis label
%\node at (3.85,-0.4){$V$};
% origin point
\draw [color=black,fill=black] (0,0) circle (0.05);
%Isokor uppvärmning
\draw [thick,->](1,1.19) -- (1,2.1);
\draw [thick](1,2.1) -- (1,3.5)node[above,scale=0.7]{2};
%Isentropisk expansion
\draw[ thick,domain=1:3, smooth, variable=\x, black] plot ({\x}, {(0.5+(3.5-0.5)*(abs((\x-3)/(1-3)))^2});
\draw[ thick,->,domain=1:1.7, smooth, variable=\x, black] plot ({\x}, {(0.5+(3.5-0.5)*(abs((\x-3)/(1-3)))^2});
\draw[ thick,domain=1.8:3, smooth, variable=\x, black] plot ({\x}, {(0.5+(3.5-0.5)*(abs((\x-3)/(1-3)))^2});
%Want to use the below instead
% \coordinate (A) at (1,3.5);
%\foreach \x in {1,...,3}{
%\coordinate (B) at (\x,{(0.5+(3.5-0.5)*(abs((\x-3)/(1-3)))^2});
%%\draw[thick, black] (A)--(B) ;
%\ifthenelse{\x = 2.5}{\draw[thick,->,smooth, black] (A)--(B) ;}{\draw[thick,smooth, black] (A)--(B) ;}
%\coordinate (A) at (B);
%}
%Isoterm kompression
\node[scale=0.7, right] at (3,0.5) {3};
\draw[ thick,->,domain=3:1.7, smooth, variable=\x, black] plot ({\x}, {1/\x + 0.18});
\draw[ thick,domain=1.7:1, smooth, variable=\x, black] plot ({\x}, {1/\x + 0.18}); 
\node[scale=0.7, left] at (1,1.19) {1};
%Små streck på p-axeln 
\draw  (0.2,1.19) -- (-0.2,1.19) node[left] {$p_1$};
%\node at (-1,1.19) {$p_1$};
\draw  (0.2,3.5)--(-0.2,3.5) node[left] {$p_2$};
\draw  (0.2,0.5)--(-0.2,0.5) node[left] {$p_3$};
%\node at (-1,3.5)  {$p_2$};
%Små streck på V-axeln
\draw (1,0.2) -- (1,-0.2) node[below]{$V_1$};
%\node at (1, -1) {$V_1$};
\draw (3,0.2) -- (3,-0.2) node[below]{$V_2$};;
%\node at (2.5,-1) {$V_2$};
\end{tikzpicture}
}
%      \caption{Mät2 }
\label{fig1}
%  
%%%%%%%%%%%%%%%%%%%%%%%%%%%T-s-diagram
\subfigure[$T\mhyphen s$ diagram]
{
\begin{tikzpicture}[scale=.4,baseline={(0,0)}]

%\draw (0,0) grid (4,4);
% x-axis
\draw [thick,->] (0,0) -- (4,0) node[right]{$s$};
% y-axis
\draw [thick,->] (0,0) -- (0,4) node[above]{$T$};
% x-axis label
%\node at (-0.3,4){$T$};
% y-axis label
%\node at (4,-0.3){$s$};
%origin point
\draw [color=black,fill=black] (0,0) circle (0.05);
%Isokor uppvärmning
\node[scale=0.7,left] at (1,0.83){1};
\draw[ ->,rotate=7,thick,domain=1:2, smooth, variable=\x, black] plot ({\x}, {(0.7 + (\x-1)^2});
\draw[ rotate=7,thick,domain=2:2.5, smooth, variable=\x, black] plot ({\x}, {(0.7 + (\x-1)^2}) node[scale=0.7,above]{2};
%Isentropis expansion
\draw [thick,->] (2.15,3.25) -- (2.15,1.9);
\draw [thick] (2.15,1.9) -- (2.15,0.83) node[scale=0.7,right]{3};
%Isoterm kompression
\draw [thick,->] (2.15,0.83) -- (1.5,0.83);
\draw [thick] (1.5,0.83) -- (0.98,0.83);
%Små streck på T-axeln 
\draw  (0.2,0.83) -- (-0.2,0.83) node[left] {$T_1$};
%\node at (-1,0.83) {$T_1$};
\draw (0.2,3.25) -- (-0.2,3.25) node[left] {$T_2$} ;
%\node at (-1,3.25)  {$T_2$};
%Små streck på s-axeln
\draw (0.98,0.2) -- (0.98,-0.2) node[below] {$s_1$};
%\node at (0,98, -1) {$s_1$};
\draw (2.15,0.2) -- (2.15,-0.2) node[below] {$s_2$};
%\node at (2.5,-1) {$s_2$};

\end{tikzpicture}
}
%    \caption{Mät 2}
\label{fig2}
%\caption{Anpassning av $n$ i $p=\frac{C}{V^n}$}
\end{figure}

Lots of texts and equations omitted

%\end{multicols}
\end{document}
2
  • 4
    \documentclass[twocolumn]{book} not \documentclass{book}[twocolumn] Commented May 22, 2022 at 19:18
  • Thank you David! :-) Commented May 22, 2022 at 20:53

0

You must log in to answer this question.

Browse other questions tagged .