You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX技术咨询:如何用chemfig或tikz创建水平六边形链?

用chemfig绘制水平六边形链

chemfig专门用于化学结构绘制,可通过控制键的走向轻松实现水平六边形链:

基本水平链示例

\documentclass{article}
\usepackage{chemfig}
\begin{document}
% 3个水平连接的六边形
\chemfig{*6(-=-=-=)-*6(-=-=-=)-*6(-=-=-=)}
\end{document}

每个*6(-=-=-=)代表一个六边形,通过-直接连接相邻顶点实现水平排列。如需调整间距,可在连接键中加入长度参数,比如-[0.8]缩短键长。

带虚线的水平链(表示任意数量)

用chemfig的虚线键样式即可实现中间重复单元的示意:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
% 两端完整六边形,中间虚线代表任意数量单元
\chemfig{*6(-=-=-=)-[,,,,dashed]-*6(-=-=-=)}

% 带重复次数标注的版本
\chemfig{*6(-=-=-=)-[,,,,dashed]{\textit{n}}-*6(-=-=-=)}
\end{document}
用TikZ绘制水平六边形链

TikZ灵活性更高,可自定义六边形样式、位置及虚线部分:

基本水平链示例

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[hexagon/.style={regular polygon, regular polygon sides=6, draw, minimum size=1cm}]
    % 水平排列3个六边形,间距保证边贴合
    \node[hexagon] (h1) at (0,0) {};
    \node[hexagon] (h2) at (1.5,0) {};
    \node[hexagon] (h3) at (3,0) {};
    % 可选:强调相邻六边形的连接
    \draw (h1.east) -- (h2.west);
    \draw (h2.east) -- (h3.west);
\end{tikzpicture}
\end{document}

带虚线的水平链

通过虚线连接两端六边形,或用虚线六边形占位示意重复单元:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[hexagon/.style={regular polygon, regular polygon sides=6, draw, minimum size=1cm},
                    dashed hex/.style={hexagon, dashed}]
    % 方案1:纯虚线连接两端
    \node[hexagon] (h1) at (0,0) {};
    \draw[dashed] (h1.east) -- (2,0);
    \node[hexagon] (h2) at (3,0) {};
    \draw[dashed] (2,0) -- (h2.west);

    % 方案2:虚线六边形+重复次数标注
    \begin{scope}[shift={(5,0)}]
        \node[hexagon] (h3) at (0,0) {};
        \node[dashed hex] (h4) at (1.5,0) {\textit{n}};
        \node[hexagon] (h5) at (3,0) {};
        \draw (h3.east) -- (h4.west);
        \draw (h4.east) -- (h5.west);
    \end{scope}
\end{tikzpicture}
\end{document}

内容的提问来源于stack exchange,提问作者phys

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 03:50:13