
두 분자(중앙 및 중간 공간 조정 가능) 위로 상자를 확장하지만 환경 내의 경계는 어떻게 확장합니까 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에 첨부했습니다. – 데이브2627
@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}