I just recently started using LaTeX and chemfig
and have a question in regard with making a new line in the text below or above the reaction arrow. I am trying to place MW, 160 °C, 5 min under Na₂CO₃, H₂O as a new line. I will greatly appreciate any help!
[Tex/LaTex] Chemfig new line reaction scheme
chemfigline-breaking
Related Solutions
Simply use the optional argument of \arrow
:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\schemestart
A + B \arrow[-90] AB
\schemestop
\end{document}
Update responding to edit of the question:
You can combine the use of \subscheme
with the invisible arrow type 0
:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
% uncomment to see internal compound names:
% \schemedebug{true}
\schemestart
\subscheme{A} + B \arrow AB
% insert arrow typ 0 (invisible) starting from compound `c2'
% scaled to 0.1 of the standard arrow length and pointing down
\arrow(@c2--){0}[-90,.1] +
% insert arrow typ 0 (invisible) scaled to 0.1 of the standard
% arrow length and pointing down
\arrow{0}[-90,.1] C
\arrow[-90] AC
\schemestop
\end{document}
The \arrow
command is a bit complex and you have to play a bit with it to get to know it. Here are a few examples of the syntax:
\arrow% simple arrow to the right
\arrow{<=>}% equilibrium arrow
\arrow{<=>[a][b]}% equilibrium arrow with labels
\arrow[-90]% arrow pointing down
\arrow{<=>[*{0}a][*{30}b]}[45]% equilibrium arrow pointing 45 degrees up with rotated labels
I repeat my advice from my answer to your previous question: study part V Reaction Schemes in the chemfig
manual. Play with its lots of examples, copy them, change the parameters and see what happens...
I'll answer under the assumption that you're the one who emailed me the other day about Missing bond type in chemical rendering packages? and to whom I suggested the following definition of the submol {Rsubst}
:
\tikzset{
subst/.style={shorten <= 10pt,preaction={draw=white,line width=6pt}}
}
\definesubmol{subst}{-[,-1,,,draw=none]-[::-30,1.5,,,subst]}
\definesubmol{Rsubst}{!{subst}R}
\definesubmol{Xsubst}{!{subst}X}
since a submol {Rsubst}
is used in your code but never defined. If that is wrong please correct me.
Your first and second question are actually the same: captions and a list of <thingy>
both are properties of floats. The real question therefore is: how to define a new float?
Since you're already using the caption
package I suggest to use the newfloat
package for defining a {scheme}
environment analogous to the {figure}
and {table}
environments. The package is from the same author and will work together nicely.
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext = los , % name of file extension
name = Scheme , % name of float type
within = chapter ,% counter within
placement = htbp % default placement
]{scheme}
This also defines a \listofschemes
which will (after two compilations) give the list of schemes.
A few remarks to your scheme: I don't understand what you mean with “line up” in your third question but I made some adjustments:
- I used the fourth possibility of stacking stuff in arrow labels from my answer to your question Chemfig new line reaction scheme. This means: no need for the
\parbox
. - I deleted the
\rlap{...}
constructs as I don't think they're needed. TheR^2
substituents can be adjusted withchemfig
's|
syntax for dividing atoms and the use of the arrival option of bonds, see another answer of mine. - I used an invisible arrow (type
0
) of length0
to center the plus with respect to the preceding molecule. There are other ways but I find this way the most convenient one in most cases. - I introduced the packages
siunitx
andchemmacros
for typesetting of units and for typesetting of chemical formulae. - I shortened the bond length of the molecules in the scheme by setting
\setatomsep{1.8em}
.
The result of all of the above is this, page one:
and on page two:
Here's the whole code:
\documentclass[12pt,letterpaper]{report}
\usepackage{chemfig}
% make the arrow label nodes center aligned. This will also allow to use \\ in
% the arrow labels and will make the use of \parbox unnecessary
\usepackage{regexpatch}
\makeatletter
% \xpatchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
% the starred variant replaces all occurrences of <search>
\xpatchcmd*\CF@arrow@display@label@i
{node[}% search
{node[align=center,}% replace
{}% success
{}% failure
\makeatother
% define the substituent submol:
\tikzset{
subst/.style={shorten <= 10pt,preaction={draw=white,line width=4pt}}
}
\definesubmol{subst}{-[,-1,,,draw=none]-[::-30,1.5,,,subst]}
\definesubmol{Rsubst}{!{subst}R}
\definesubmol{Xsubst}{!{subst}X}
% use other useful chemistry tools, too, e.g. the handy \ch command:
\usepackage{chemmacros}
% set units in a unified way:
\usepackage{siunitx}
\DeclareSIUnit{\molpercent}{mol\%}
% customize captions, define floating scheme environment:
\usepackage{caption}
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext = los ,
name = Scheme ,
within = chapter ,
placement = htbp
]{scheme}
\begin{document}
\listofschemes
\chapter{Foo Bar}
\begin{scheme}
\footnotesize\centering
\setatomsep{1.8em}
\schemestart[0,2.5,thick]
\chemfig{*6(
-(!{Rsubst})
=-(-[,0.8]I)
=(-[,0.9]N(-[:150,1.3,,1]R|^2)(-[:30,1.3]R|^1))
-=)
}
\arrow{0}[,0]\+
\chemfig{R^4-~}
\arrow{->%
[\SI{3}{\molpercent}, \ch{PdCl2(PPh)3}\\ \SI{2}{\molpercent},\ch{CuI}, \ch{Et3N}]%
[MW, \SI{60}{\degree}, \SI{20}{\minute}]}
\chemfig{*6(
-(!{Rsubst})
=-(-~-R|^4)
=(-[,0.9]N(-[:150,1.3,,1]R|^2)(-[:30,1.3]R|^1))
-=)
}
\schemestop
\caption{Microwave assisted Sonogashira coupling reaction.}
\end{scheme}
\end{document}
Best Answer
You could place the arrow's label's contents in a
\parbox
:or for convenience define a command:
The arrow's labels are tikz nodes. If we were able to set add
align=center
to their properties we would not need the\parbox
. Unfortunatelychemfig
doesn't provide an interface to access their properties directly. The nodes are placed by a command\CF@arrow@display@label@i
which we could redefine:The last manual redefinition can be done easier with @egreg's
regexpatch
package: