对于视觉表现,我需要将图片、方程式和化学式以网格形式排列。然而,这比我想象的要难得多。
其次,我尝试了一下TikZ
,它给出了一个很好的布局,但是当我dummytext
用\chemfig
命令替换它时,它就完全混乱了。
有没有简单的解决办法?我知道我可以将方程式和公式转换为单独的图片,并使用 包含它们\includegraphics
,但每次更改都需要多次重新编译。
以下是相应的 MWE:
\documentclass[11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage[a5paper, landscape, left=10mm, right=10mm, top=15mm, bottom=15mm]{geometry}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{tabu, multirow}
\usepackage{chemfig}
%% for the whole Tikz stuff
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart, shapes.misc, matrix, positioning}
\tikzstyle{fotobox}=[
rectangle, rounded corners=1mm,
draw=black, very thick,
text centered, text width=0.6\textwidth]
\tikzstyle{textbox}=[
rectangle, rounded corners=1mm,
draw=black, very thick,
text width=0.3\textwidth]
\begin{document}
%% load the pictures from the web, if necessary
\IfFileExists{./infrarotPlot.pdf}
{}
{
\write18{wget -O ./infrarotPlot.pdf http://pgfplots.net/media/tikz/examples/PDF/infrared.pdf}
}
\pagestyle{empty}
\begin{tikzpicture}
\node(diagramm)[fotobox, ] at (0,0)
{\includegraphics[width=\textwidth]{infrarotPlot} \\ Nice diagram};
\node(mathe)[textbox, right=of diagramm.north east, anchor=north west, text height=0.2\textheight]
{$E = m c^2 + 1$};
\node(chemie)[textbox, right=of diagramm.south east, anchor=south west, text height=0.5\textheight]
{Dummytext for chemical formula};
\end{tikzpicture}
\newpage
\begin{tabu}{X[l,m] X[c,m]}
\multirow{2}{*}{\includegraphics[width=0.6\textwidth]{infrarotPlot}} & $E = m c^2$ \\
& \chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}
\end{tabu}
\end{document}
答案1
这里有三种方法可以实现这一点。
第一个使用普通的表格,嵌套。唯一的技巧是使用
\raisebox{-0.5\height}{\includegraphics[width=0.4\textwidth]{example-image}}
第二个使用多列,不需要任何技巧。
第三个使用tikz
。由于\chemfig
不能在 tikz 节点内部使用(因为公式本身就是 tikz 图片),我们首先将 tikz 图片外部的公式排版为savebox
,然后在 tikz 节点内部使用这个框。
\newsavebox\formula
\savebox\formula{\chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}}
...
\node(chemie)[...] {\usebox\formula};
\documentclass[11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage[a5paper, landscape, left=10mm, right=10mm, top=15mm, bottom=20mm]{geometry}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{tabu, multirow}
\usepackage{chemfig}
%% for the whole Tikz stuff
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart, shapes.misc, matrix, positioning}
\tikzstyle{fotobox}=[
rectangle, rounded corners=1mm,
draw=black, very thick,
text centered, text width=0.4\textwidth]
\tikzstyle{textbox}=[
rectangle, rounded corners=1mm,
draw=black, very thick,
text width=0.3\textwidth]
\begin{document}
\begin{tabular}{cc}
\raisebox{-0.5\height}{\includegraphics[width=0.4\textwidth]{example-image}}&
\begin{tabular}{c}
$E = m c^2$\\[5ex]
\chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}
\end{tabular}
\end{tabular}
\newpage
\begin{multicols}{2}
\includegraphics[width=0.4\textwidth]{example-image}
\columnbreak
\vspace*{\fill}
$E = m c^2$
\vfill
\chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}
\vspace*{\fill}
\end{multicols}
\newpage
\newsavebox\formula
\savebox\formula{\chemfig{[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3}}
\begin{tikzpicture}
\node(diagramm)[fotobox, ] at (0,0)
{\includegraphics[width=\textwidth]{example-image} \\ Nice diagram};
\node(mathe)[textbox, right=of diagramm.north east, anchor=north west]
{$E = m c^2 + 1$};
\node(chemie)[textbox, right=of diagramm.south east, anchor=south west]
{\usebox\formula};
\end{tikzpicture}
\end{document}