6

I have two questions on the following package combination of the MWE: First, how to shift part number/label while using tcolorbox?

\documentclass[a4paper,12pt]{exam} \usepackage{tikz} \usetikzlibrary{arrows,circuits.ee.IEC,positioning} \usetikzlibrary{decorations.markings} \usepackage[american voltages, american currents,siunitx]{circuitikz} \usepackage{graphicx,ctable,booktabs,float} \usepackage[most]{tcolorbox} \tcbuselibrary{skins,breakable} \usepackage[labelformat=simple]{subcaption} \usepackage{caption} \captionsetup[figure]{name=Fig.,font=footnotesize} \captionsetup[subfigure]{labelformat = parens, labelsep = space, font = footnotesize} \begin{document} \printanswers \unframedsolutions \begin{questions} \question For the network shown in Fig.~\ref{fig:2015q1a},\label{Q1}\par% \begin{minipage}[t]{0.5\textwidth} \begin{parts} \part Draw a complete graph.\label{2015q1a} \part Obtain a tie-set matrix by selecting a tree of your choice from the graph of (\ref{2015q1a}). \part Determine a cut-set matrix by selecting another tree from the graph of (\ref{2015q1a}). \end{parts} \end{minipage} \begin{minipage}[t]{0.5\textwidth} \vspace{-2.5em}% \centering% \scalebox{0.7}{% \begin{tikzpicture}[circuit ee IEC, x=3.5cm, y=3.5cm] \draw (1.6,0) to (0,0.0) to [V, l=5<\volt>] (0,1.0); \draw (0.0,1.0) to [R,l=47<\kilo\ohm>,*-*] (0.8,1.0); \draw (0.8,0) to [C,l=247<\mu\farad>,*-*] (0.8,1.0); \draw (0.8,1.0) to [cV, l_=$0.7\color{black}{i_x}$,-*] (1.6,1.0); \draw (1.6,0.0) to [R,l_=1<\kilo\ohm>] (1.6,1.0); \draw (0,1.0) to (0,1.4) to [L, l=2.5<\milli\henry>] (1.6,1.4) to (1.6,1.0); \draw[black,-stealth] (1.3,1.45) to node[above]{$i_x$} (1.45,1.45); \end{tikzpicture} }% end of scalebox \captionof{figure}{} \label{fig:2015q1a} \end{minipage} % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \setcounter{figure}{0} %<<>><<>><<>> \setcounter{equation}{0} %<<>><<>><<>> \renewcommand{\thefigure}{\thequestion(\roman{figure})} %<<>><<>><<>> \renewcommand{\theequation}{\thequestion.\arabic{equation}} %<<>><<>><<>> % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \begin{solution} \begin{parts} % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \part % - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \begin{tcolorbox}[enhanced, frame style={left color=black!5,right color=black!35,middle color=black!5!pink}, interior style={left color=green!10!white, right color=gray!10!white}, boxrule=1pt, sharpish corners, top=4pt, bottom=5pt, left=0pt, right=0pt] % - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Given circuit is redrawn and a complete directed graph is obtained from it: % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \begin{figure}[H] \centering% \begin{subfigure}[t]{0.4\textwidth} \centering% \scalebox{0.6}{% \begin{tikzpicture}[circuit ee IEC,x=2.5cm,y=2.5cm,semithick,every info/.style={font=\normalsize}] \coordinate [label=left:\textcolor{blue}{$1$}] (A) at (0.0,1.6); \coordinate [label=\textcolor{blue}{$2$}] (B) at (1.0,1.5); \coordinate [label=below:\textcolor{blue}{4}] (C) at (1.0,0.0); \coordinate [label=right:\textcolor{blue}{$3$}] (D) at (2.0,1.6); \draw (1.0,0.0) to [V, l=9<\volt>,*-*,label/align=straight] (0.0,1.5); \draw (1.0,0.0) to (1.0,0.5) to [R, l=5<\kilo\ohm>,label/align=straight] (1.0,1.5); \draw (1.0,0.0) to [resistor, l_=7<\kilo\ohm>,*-*,label/align=straight] (2.0,1.5); \draw (0.0,1.5) to [cV,l=0.4$i_x$,label/align=straight] (1.0,1.5); \draw (1.0,1.5) to [resistor, l=2<\kilo\ohm>, *-] (2.0,1.5); \draw (2.0,1.5) to [bend right=25] (1.2,2.3) to [R,l_=2.5<\kilo\ohm>] (0.8,2.3) to [bend right=25] (0.0,1.5); \draw [->] (1.1,1.3) to node[below]{$i_x$} (1.4,1.3); \end{tikzpicture} } \caption{Given circuit is redrawn.} \label{SFQ1a1} \end{subfigure} \quad% \begin{subfigure}[t]{0.4\textwidth} \centering% \scalebox{0.6}{% \begin{tikzpicture}[decoration={markings, mark=at position 0.57 with {\arrow[scale=2]{latex'}}},font=\large] \coordinate [label=left:\textcolor{blue}{$1$}] (A) at (0.1,3.8); \coordinate [label=above:\textcolor{blue}{$2$}] (B) at (2.5,3.8); \coordinate [label=right:\textcolor{blue}{$3$}] (C) at (4.8,3.8); \coordinate [label=below:\textcolor{blue}{$4$}] (D) at (2.5,-0.15); \draw[postaction={decorate},thick] (0.1,3.72) to [bend right=-50] node[above] {$a$} (4.8,3.8); \draw[postaction={decorate},thick] (0.2,3.8) to node[above] {$b$} (2.5,3.8); \draw[postaction={decorate},thick] (2.5,3.8) to node[above] {$c$} (4.8,3.8); \draw[postaction={decorate},thick,*-*] (2.55,-0.25) to node[left] {$d$} (0.1,3.85); \draw[postaction={decorate},thick,*-] (2.5,3.88) to node[right] {$e$} (2.5,-0.2); \draw[postaction={decorate},thick,*-] (4.8,3.88) to node[right] {$f$} (2.5,-0.2); \end{tikzpicture} }%end of scalebox \caption{Complete directed graph of \subref{SFQ1a1}.} \label{SFQ1a2} \end{subfigure} \caption{Construction of graph from the given electrical circuit.} \label{fig:Q1a} \end{figure} % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \end{tcolorbox} \part A tree with twigs, $twigs$:\{b,c,e\}, has been selected by solid lines while links dashed lines in the graphs of Fig.~\ref{fig:Q1a}\subref{SFQ1a2}.% \end{parts} \end{solution} \end{questions} \end{document} 

Secondly, question is to how to enclose with parenthesis in subfigure reference? Reference output: enter image description here

Can anybody help me please?

1
  • Two different questions asked? The first: box align=top, however not perfect Commented Dec 14, 2015 at 17:37

1 Answer 1

4

box align=top will shift the (a) part number to the top, but a little bit too much.

\captionsetup{subrefformat=parens} will yield (a) for the reference.

\documentclass[a4paper,12pt]{exam} \usepackage{tikz} \usetikzlibrary{arrows,circuits.ee.IEC,positioning} \usetikzlibrary{decorations.markings} \usepackage[american voltages, american currents,siunitx]{circuitikz} \usepackage{graphicx,ctable,booktabs,float} \usepackage[most]{tcolorbox} \tcbuselibrary{skins,breakable} \usepackage[labelformat=simple]{subcaption} \usepackage{caption} \captionsetup[figure]{name=Fig.,font=footnotesize} \captionsetup[subfigure]{labelformat = parens, labelsep = space, font = footnotesize,subrefformat=parens} \begin{document} \printanswers \unframedsolutions \begin{questions} \question For the network shown in Fig.~\ref{fig:2015q1a},\label{Q1}\par% \begin{minipage}[t]{0.5\textwidth} \begin{parts} \part Draw a complete graph.\label{2015q1a} \part Obtain a tie-set matrix by selecting a tree of your choice from the graph of (\ref{2015q1a}). \part Determine a cut-set matrix by selecting another tree from the graph of (\ref{2015q1a}). \end{parts} \end{minipage} \begin{minipage}[t]{0.5\textwidth} \vspace{-2.5em}% \centering% \scalebox{0.7}{% \begin{tikzpicture}[circuit ee IEC, x=3.5cm, y=3.5cm] \draw (1.6,0) to (0,0.0) to [V, l=5<\volt>] (0,1.0); \draw (0.0,1.0) to [R,l=47<\kilo\ohm>,*-*] (0.8,1.0); \draw (0.8,0) to [C,l=247<\mu\farad>,*-*] (0.8,1.0); \draw (0.8,1.0) to [cV, l_=$0.7\color{black}{i_x}$,-*] (1.6,1.0); \draw (1.6,0.0) to [R,l_=1<\kilo\ohm>] (1.6,1.0); \draw (0,1.0) to (0,1.4) to [L, l=2.5<\milli\henry>] (1.6,1.4) to (1.6,1.0); \draw[black,-stealth] (1.3,1.45) to node[above]{$i_x$} (1.45,1.45); \end{tikzpicture} }% end of scalebox \captionof{figure}{} \label{fig:2015q1a} \end{minipage} % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \setcounter{figure}{0} %<<>><<>><<>> \setcounter{equation}{0} %<<>><<>><<>> \renewcommand{\thefigure}{\thequestion(\roman{figure})} %<<>><<>><<>> \renewcommand{\theequation}{\thequestion.\arabic{equation}} %<<>><<>><<>> % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \begin{solution} \begin{parts} % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \part\vadjust{\vspace{-3.3\baselineskip}}\newline % - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \begin{tcolorbox}[enhanced, frame style={left color=black!5,right color=black!35,middle color=black!5!pink}, interior style={left color=green!10!white, right color=gray!10!white}, boxrule=1pt, sharpish corners, top=4pt, bottom=5pt, left=0pt, right=0pt,box align=top] % - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Given circuit is redrawn and a complete directed graph is obtained from it: % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \begin{figure}[H] \centering% \begin{subfigure}[t]{0.4\textwidth} \centering% \scalebox{0.6}{% \begin{tikzpicture}[circuit ee IEC,x=2.5cm,y=2.5cm,semithick,every info/.style={font=\normalsize}] \coordinate [label=left:\textcolor{blue}{$1$}] (A) at (0.0,1.6); \coordinate [label=\textcolor{blue}{$2$}] (B) at (1.0,1.5); \coordinate [label=below:\textcolor{blue}{4}] (C) at (1.0,0.0); \coordinate [label=right:\textcolor{blue}{$3$}] (D) at (2.0,1.6); \draw (1.0,0.0) to [V, l=9<\volt>,*-*,label/align=straight] (0.0,1.5); \draw (1.0,0.0) to (1.0,0.5) to [R, l=5<\kilo\ohm>,label/align=straight] (1.0,1.5); \draw (1.0,0.0) to [resistor, l_=7<\kilo\ohm>,*-*,label/align=straight] (2.0,1.5); \draw (0.0,1.5) to [cV,l=0.4$i_x$,label/align=straight] (1.0,1.5); \draw (1.0,1.5) to [resistor, l=2<\kilo\ohm>, *-] (2.0,1.5); \draw (2.0,1.5) to [bend right=25] (1.2,2.3) to [R,l_=2.5<\kilo\ohm>] (0.8,2.3) to [bend right=25] (0.0,1.5); \draw [->] (1.1,1.3) to node[below]{$i_x$} (1.4,1.3); \end{tikzpicture} } \caption{Given circuit is redrawn.} \label{SFQ1a1} \end{subfigure} \quad% \begin{subfigure}[t]{0.4\textwidth} \centering% \scalebox{0.6}{% \begin{tikzpicture}[decoration={markings, mark=at position 0.57 with {\arrow[scale=2]{latex'}}},font=\large] \coordinate [label=left:\textcolor{blue}{$1$}] (A) at (0.1,3.8); \coordinate [label=above:\textcolor{blue}{$2$}] (B) at (2.5,3.8); \coordinate [label=right:\textcolor{blue}{$3$}] (C) at (4.8,3.8); \coordinate [label=below:\textcolor{blue}{$4$}] (D) at (2.5,-0.15); \draw[postaction={decorate},thick] (0.1,3.72) to [bend right=-50] node[above] {$a$} (4.8,3.8); \draw[postaction={decorate},thick] (0.2,3.8) to node[above] {$b$} (2.5,3.8); \draw[postaction={decorate},thick] (2.5,3.8) to node[above] {$c$} (4.8,3.8); \draw[postaction={decorate},thick,*-*] (2.55,-0.25) to node[left] {$d$} (0.1,3.85); \draw[postaction={decorate},thick,*-] (2.5,3.88) to node[right] {$e$} (2.5,-0.2); \draw[postaction={decorate},thick,*-] (4.8,3.88) to node[right] {$f$} (2.5,-0.2); \end{tikzpicture} }%end of scalebox \caption{Complete directed graph of \subref{SFQ1a1}.} \label{SFQ1a2} \end{subfigure} \caption{Construction of graph from the given electrical circuit.} \label{fig:Q1a} \end{figure} % ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \end{tcolorbox} \part A tree with twigs, $twigs$:\{b,c,e\}, has been selected by solid lines while links dashed lines in the graphs of Fig.~\ref{fig:Q1a}\subref{SFQ1a2}.% \end{parts} \end{solution} \end{questions} \end{document} 

enter image description here

6
  • subrefformat=parens under \captionsetup[subfigure]{...} did magic for second question but first question part number alignment still needs improvement I believe. However, I am thankful to you for this suggestion! Commented Dec 14, 2015 at 17:54
  • @Khaaba: I think the alignment is a exam issue actually Commented Dec 14, 2015 at 18:52
  • 1
    I found a solution from here tex.stackexchange.com/questions/5023/… doing this way: \part \leavevmode\vadjust{\vspace{-3.3\baselineskip}}\newline \begin{tcolorbox}[... Commented Dec 15, 2015 at 2:47
  • @Khaaba: Shall I add this to my solution or will you post a self-answer? Commented Dec 15, 2015 at 8:16
  • Please add to your solution so that it makes a complete answer. Commented Dec 16, 2015 at 2:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.