
両方の分子の上にボックスを拡張するにはどうすればよいでしょうか (中央に配置され、中間スペースは調整可能)。ただし、enumerate
環境内の境界は拡張できますか? この画像は私が作成したいものです。次のことを実行しようとしましたが、明らかに大きさが足りません。
\documentclass{article}
\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\usepackage[version=4,arrows=pgf]{mhchem}
\usepackage{amsmath}
\usepackage{tabu}
\usepackage{framed}
\definecolor{SolutionColor}{gray}{0.85}
\usepackage{linegoal}
\newcommand{\mybox}[1]{\colorbox{SolutionColor}{\parbox[t]{\linegoal}{#1}}}
\begin{document}
\begin{enumerate}
\item Are the compounds shown below isomers?
\begin{center}
\mybox{
{\tabulinesep=1.6mm
\begin{tabu}{cc}
\chemfig[double bond sep=0.3em,atom sep=2.5em]{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-C(-[2]H)(-[6]H)-H} & \chemfig[double bond sep=0.3em,atom sep=2.5em]{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-H}
\end{tabu}}
}
\end{center}
Yes or No
Why?
\item Are the following geometric isomers?
\begin{center}
\chemfig[double bond sep=0.3em,atom sep=2.5em]{H_3C-[:-60,,2]C(-[:-120]H)=C(-[:-60]CH_3)-[:60]H}
\hspace{1em}
\chemfig{@{H}}
\hspace{1em}
\chemfig[double bond sep=0.3em,atom sep=2.5em]{H_3C-[:-60,,2]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]H}
\end{center}
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=gray,opacity=0.4]($(H.north east)+(6cm,1cm)$)rectangle($(H.south west)+(-5cm,-1cm)$);
\end{tikzpicture}
\end{enumerate}
\end{document}
答え1
これは厳密には解決策ではありませんが、別のアプローチです。tcolorbox を使用すると、ボックスを必要に応じて拡張できます。
\documentclass{article}
\usepackage{chemfig}
\usepackage{tcolorbox}
\definecolor{SolutionColor}{gray}{0.85}
\begin{document}
\begin{enumerate}
\item Are the compounds shown below isomers?
\begin{tcolorbox}[colback=SolutionColor, sharp corners, boxrule=0pt, left=2mm, right=2mm, top=4mm, bottom=1cm]
\centering
\setchemfig{double bond sep=0.3em,atom sep=2.5em}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-C(-[2]H)(-[6]H)-H}
\hspace{5mm}
\chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-H}
\end{tcolorbox}
Yes or No
Why?
\end{enumerate}
\end{document}
答え2
\documentclass{article}
\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\usepackage[version=4,arrows=pgf]{mhchem}
\usepackage{amsmath}
\usepackage{tabu}
\usepackage{framed}
\definecolor{SolutionColor}{gray}{0.85}
\usepackage{linegoal}
\newcommand{\mybox}[1]{\colorbox{SolutionColor}{\parbox[t]{\linegoal}{#1}}}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{enumerate}
\item Are the compounds shown below isomers?\\
\begin{center}
\chemfig[
double bond sep=0.3em,
atom sep=2.5em
]
{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-C(-[2]H)(-[6]H)-@{H}H}
\qquad
\chemfig[
double bond sep=0.3em,
atom sep=2.5em
]
{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-H}
\end{center}
Yes or No
\\
Why?
\end{enumerate}
\begin{tikzpicture}[remember picture, overlay]
\draw[red,fill=gray,opacity=0.5]($(H.north east)+(6cm,1cm)$)rectangle($(H.south
west)+(-5cm,-1cm)$);
\end{tikzpicture}
\end{document}
上記のコメント欄のOPの質問に対応するために編集します
@jsbibra 申し訳ありませんが、分子が直線でない場合、tikz アンカー @{H} をどのように変更すればよいでしょうか? 上記の MWE に添付しました。 – Dave2627
最初の例で使用されているため、@Hをタグとして再度選択するとtikzが混乱する可能性があります。@XYZなどの別のアルファベットをタグとして使用して先に進んでください。
\documentclass{article}
\usepackage{chemfig,chemmacros}
\chemsetup{modules=all}
\usepackage[version=4,arrows=pgf]{mhchem}
\usepackage{amsmath}
\usepackage{tabu}
\usepackage{framed}
\definecolor{SolutionColor}{gray}{0.85}
\usepackage{linegoal}
\newcommand{\mybox}[1]{\colorbox{SolutionColor}{\parbox[t]{\linegoal}{#1}}}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{enumerate}
\item Are the compounds shown below isomers?\\
\begin{center}
\chemfig[
double bond sep=0.3em,
atom sep=2.5em
]
{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-C(-[2]H)(-[6]H)-@{H}H}
\qquad
\chemfig[
double bond sep=0.3em,
atom sep=2.5em
]
{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]OH)(-[6]H)-H}
\end{center}
Yes or No
\\
Why?
\\
\item Are the following geometric isomers?
\begin{center}
\chemfig[double bond sep=0.3em,atom sep=2.5em]{H_3C-[:-60,,2]C(-[:-120]H)=C(-[:-60]CH_3)-[:60]@{X}H}
\hspace{1em}
% \chemfig{@{H}}
\hspace{1em}
\chemfig[double bond sep=0.3em,atom sep=2.5em]{H_3C-[:-60,,2]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]H}
\end{center}
\end{enumerate}
\begin{tikzpicture}[remember picture, overlay]
\draw[red,fill=gray,opacity=0.5]($(H.north east)+(6cm,1cm)$)rectangle($(H.south
west)+(-5cm,-1cm)$);
\draw[blue,line width=2pt,fill=teal,opacity=0.3]($(X.north east)+(5cm,4pt)$)rectangle($(X.south
west)+(-3cm,-5em)$);
\end{tikzpicture}
\end{document}