文档从后面的页面开始。到目前为止我做了什么,但仍然看起来不太好。枚举将项目放在靠近 tcolorbox 边缘的地方。有没有办法连接 tcolorboxes 以使其看起来相似?
\documentclass[12pt,article,a4paper]{memoir}
\usepackage[croatian]{babel}
\usepackage[pdftex]{graphicx}
\usepackage[cp1250]{inputenc}
\usepackage{tikz}
\usepackage[margin=.5in]{geometry}
\usepackage{amssymb,mathtools,amsmath,amsfonts,amsthm}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage{multicol}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\sfdefault}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{array}
\usepackage{colortbl}
\tcbuselibrary{skins}
\usepackage{pdflscape}
\usepackage{lipsum}
\pagestyle{empty}
\usepackage{booktabs}
\usepackage[locale=DE]{siunitx}
\newenvironment{zad}[1]{\indent \textsc{Zadatak} $\left[#1 \right]$}{\null\hfill$\qed$\hskip 2mm\vskip 2mm}
\usetikzlibrary{positioning}
\begin{document}
\tcbset{
enhanced,colback=white!10!white,colframe=black!50!black,colbacktitle=white!30!white,
coltitle=black,arc=0pt,outer arc=0pt,
}
\begin{enumerate}
\begin{tcolorbox}[title={\item\zad{4} This is first question},sidebyside,bottom=0mm,righthand ratio=0.15]
This is a \textbf{QUESTION}.
\tcblower
\begin{enumerate}
\item A
\item B
\end{enumerate}
\end{tcolorbox}
\begin{tcolorbox}[title={\item\zad{4} This is second question},sidebyside,bottom=0mm,righthand ratio=0.15]
\[\sum_{i=0}^{n}X_{k}=\sum_{i=0}^{n}\dfrac{A_{ij}^{k}}{k!}\]
\tcblower
\begin{enumerate}
\item C
\item D
\end{enumerate}.
\end{tcolorbox}
\end{enumerate}
\end{document}`
答案1
我不太清楚您想要实现什么。链接文档中的问题与您的代码给出的问题看起来完全不同。
另外,我不太明白您\qed
在环境中试图用 实现什么zad
。所以我将向您展示 2 个解决方案。这两个解决方案都定义了一个\myquestion
带有 3 个参数的新命令:问题标题、问题本身和以分号分隔的多项选择答案列表。
第一个解决方案:
在这个解决方案中,我试图尽可能接近您自己的代码建议的布局(zad
命令,\qed
在标题中,右侧的多项选择答案,......)
\documentclass{article}
\usepackage[croatian]{babel}
\usepackage[T1]{fontenc}
\usepackage[cp1250]{inputenc}
\usepackage{xparse}
\usepackage{enumitem}
\usepackage{arydshln}
\usepackage{fullpage}
\usepackage{amsthm}
\renewcommand*\familydefault{\sfdefault}
\ExplSyntaxOn
\newcounter{questions}
\stepcounter{questions}
\renewcommand{\arraystretch}{2}
\newcommand{\zad}[1]{\textsc{Zadatak}\ $[#1]$}
\NewDocumentCommand{\myquestion}{m m m}{
\par\noindent
\begin{tabular}{|l:l|}
\hline
\multicolumn{2}{|l|}{\thequestions.\ #1 \hfill $\qed$} \\ \hline
\parbox{.75\textwidth}{#2} & \parbox{.19\textwidth}{\choices:n{#3}} \\ \hline
\end{tabular}
\stepcounter{questions}
}
\cs_new:Npn \choices:n #1{
\seq_set_split:Nnn \splitted_seq{;}{#1}
\begin{enumerate}[label=\alph*)]
\seq_map_inline:Nn \splitted_seq{
\item ##1
}
\end{enumerate}
}
\ExplSyntaxOff
\begin{document}
\myquestion{\zad{4} This is the first question}
{This is a \textbf{QUESTION}}
{choice A; choice B; choice C}
\vspace{-1pt}
\myquestion{\zad{4} This is the second question}
{\[ \sum_{i=0}^n X_k = \sum_{i=0}^n \frac{A_{ij}^k}{k!} \]}
{choice A; choice B; choice C; choice D}
\end{document}
第二种解决方案: 该解决方案与您链接到的文档更接近(问题框内的多项选择答案,带有复选框的粉红色框,...)
\documentclass{article}
\usepackage[croatian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xparse}
\usepackage{enumitem}
\usepackage{fullpage}
\usepackage{amsthm}
\usepackage[table]{xcolor}
\usepackage{arydshln}
\usepackage{tikz}
\renewcommand*\familydefault{\sfdefault}
\ExplSyntaxOn
\newcounter{questions}
\stepcounter{questions}
\renewcommand{\arraystretch}{2}
\newcommand{\tickbox}{
\begin{tikzpicture}[scale=.3]
\fill[white] (0,0) -- (0,1) -- (1,1) -- (1,0) -- cycle;
\end{tikzpicture}
}
\NewDocumentCommand{\myquestion}{m m m}{
\par\noindent
\begin{tabular}{|l:l|}
\hline
\multicolumn{2}{|l|}{\thequestions.\ #1} \\ \hline
\parbox{.85\textwidth}{\vspace{2mm} #2 \choices:n{#3}} & \cellcolor{red!15}\parbox{.09\textwidth}{\tickboxes:n{#3}} \\ \hline
\end{tabular}
\stepcounter{questions}
}
\cs_new:Npn \choices:n #1{
\seq_set_split:Nnn \splitted_seq{;}{#1}
\begin{enumerate}[label=\Alph*.]
\seq_map_inline:Nn \splitted_seq{
\item ##1
}
\end{enumerate}
}
\cs_new:Npn \tickboxes:n #1{
\seq_set_split:Nnn \splitted_seq{;}{#1}
\begin{enumerate}[label=\Alph*.]
\seq_map_inline:Nn \splitted_seq{
\item \tickbox
}
\end{enumerate}
}
\ExplSyntaxOff
\begin{document}
\myquestion{Intervals}
{Koliko cijelih brojeva ima u intervalu $\left[-\frac{11}{4},3\right\rangle$?}
{5; 6}
\vspace{-1pt}
\myquestion{Order of Operations}
{Učenik je na džepnome računalu zbrojio brojeve $A$ i $B$. Dobiveni rezultat podijelio je s $C$. Taj je rezultat pomnožio s $D$. Koji izraz opisuje taj račun?}
{$\frac{A+B}{CD}$; $\frac{(A+B)D}{C}$; $(A+B:C)\cdot D$; $A+B:\frac{c}{D}$}
\vspace{-1pt}
\myquestion{Unit Conversion}
{Kolika je gustoća $1.8$ g/cm$^3$ izražena u kg/m$^3$?}
{$0.018$ kg/m$^3$;$0.18$ kg/m$^3$;$1.8$ kg/m$^3$; $18$ kg/m$^3$; $180$ kg/m$^3$; $1800$ kg/m$^3$}
\end{document}
当然,根据您实际想要实现的目标,可以将这两种解决方案结合起来。