如何在字符之间放置箭头(文本内)

如何在字符之间放置箭头(文本内)

LaTeX 社区!

我目前正在撰写语言学学士论文,希望在文本中实现一种特定的结构。这种结构是我在出版物中遇到的,它将大大提高我的解释的可读性。通常,使用环境创建此类视觉效果tikzpicture很简单,但我的挑战在于将它们直接合并到文本流中。

文本中有带箭头的 C v CV 结构

我在用着背页我正在寻找一种方法来将这些类型的结构无缝地集成到文本本身中。为了更清楚地说明我的目标,我将附上一张从启发我的论文中摘录的图片。我想要做的是将箭头(使用 -LaTeX 箭头文本流中的字符之间(如图所示)有双箭头。理想的做法是制作弯曲的箭头,箭头位于字符的下方和上方,并且是实心的(普通箭头)或双箭头。这能实现吗?有人可以指导我如何使用 LaTeX 在文本中实现这些结构吗?任何建议或建议都将不胜感激。

预先感谢您的帮助!

我附上了图片,上面用箭头表示 C v CV 部分。还附上了我的序言。

\documentclass[12p]{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage[greek ,russian, hungarian]{babel}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{capt-of}
\usepackage{multicol}
\usepackage{pifont}
\usepackage{stackengine}
\usepackage[table,xcdraw]{xcolor}
\usepackage{tikz-qtree}
\usepackage{textcomp}
\usepackage{sectsty}
\usepackage{array}
\usepackage{bm}
\usepackage{amsmath}
\usetikzlibrary{patterns, patterns.meta, arrows.meta, decorations.pathreplacing, calligraphy, shapes.geometric}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{linguex}
\usepackage{multirow}
\allsectionsfont{\sffamily}

\AtBeginDocument{%
  \DeclareFontFamilySubstitution{T2A}{\familydefault}{Tempora-TLF}%
}

\DeclareMathAlphabet\mathbfcal{OMS}{cmsy}{b}{n}


\doublespacing

\renewcommand{\sfdefault}{cmss}
\newcommand{\sipa}[1]{\textsf{\textipa{#1}}}

\graphicspath{{Images/}}

\begin{document}

So it is a CvCV structure

\end{document}

答案1

您可以使用tikzcd内联。

在此处输入图片描述

\documentclass{article}

\usepackage{tikz-cd}
\tikzcdset{arrow style=tikz, diagrams={>=Parenthesis}}
\tikzset{inline/.style={column sep=2mm, cells={nodes={inner xsep=0pt}}}}

\begin{document}

Just some text here. Just some text here. Just some text here. Just some text here. 
Just some text here. Just some text here. Just some text here. The latter type
%
\begin{tikzcd}[inline, math mode=false]
C&v&C\arrow[ll, bend left]&[.2em]V\arrow[l, Rightarrow]\arrow[ll, bend right=45]
\end{tikzcd},
%
is the default case. Just some text here. Just some text here. Just some text here. Just some text here.
Just some text here. Just some text here. Just some text here. Just some text here. 

\end{document}

答案2

这个解决方案可以改进(并且应该改进),但至少在某种程度上是有效的。

  • 第一个参数是预空格(默认 1pt),可选
  • 第二个参数是空格后(默认 1pt)可选
  • 第三个参数(第一个必需)是节点名称
  • 第四个参数(第二个必需)是目标框(在本例中为字母)。

我删除了一些包因为我不想安装它们,并且我添加了一些前面的文本和后面的文本来检查行距。

输出

\documentclass[12pt]{article}
\usepackage[doublespacing]{setspace}
\usepackage[T2A,T1]{fontenc}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage{amsmath}
\usepackage{tikz-qtree}
\usetikzlibrary{tikzmark}
\usetikzlibrary{patterns, patterns.meta, arrows.meta, decorations.pathreplacing, calligraphy, shapes.geometric}

\NewDocumentCommand{\tmark}{O{1pt} O{1pt} m m }
{\hspace*{#1}\tikzmarknode{#3}{\rule[-2pt]{0pt}{12pt}#4}\hspace*{#2}}
\begin{document}
    
    Aliquam lectus. Vivamus leo. Quisque ornare tellus
    ullamcorper nulla. Mauris porttitor haretra tortor.
    Sed fringilla justo sed mauris. Sed non leo. Nullam 
    ullamcorper nulla. Mauris porttitor haretra tortor.
    So it is a
     \tmark{c1}{C}\tmark{v}{v}\tmark{c2}{C}\tmark[7pt]{V}{V}
    following text. Aliquam lectus. Vivamus leo. Quisque ornare
    tellus ullamcorper nulla. Mauris porttitor haretra tortor
    
    \begin{tikzpicture}[remember picture,overlay]
        \draw[-latex,black] (c2.south) to[in=-25,out=205] (c1.south);
        \draw[-latex,black] (V.north) to[in=25,out=155] (v.north);
        \draw[-{Implies},double,black] (V.west) -- (c2.east);
    \end{tikzpicture}
\end{document}

答案3

这可以通过baseline(current bounding box.base)和节点锚点设置为来实现base

\documentclass{report}
\usepackage[doublespacing]{setspace}
\usepackage{tikz}
\newcommand{\inlinestructure}{%
\tikz[baseline=(current bounding box.base)]{
\node (l1) [anchor=base,inner sep=0pt]{C};
\node (l2) [anchor=base,inner sep=0pt,xshift=12pt] at (l1.base){v};
\node (l3) [anchor=base,inner sep=0pt,xshift=12pt] at (l2.base){C};
\node (l4) [anchor=base,inner sep=0pt,xshift=12pt] at (l3.base){$\Leftarrow$};
\node (l5) [anchor=base,inner sep=0pt,xshift=12pt] at (l4.base){V};
\draw [-latex] ([yshift=-2pt]l3.south west) to[out=-155,in=-25] ([yshift=-2pt]l1.south east);
\draw [-latex] ([yshift=2pt]l5.north west) to[out=155,in=25] ([yshift=4pt]l2.north east);}\nobreakspace%
}

\begin{document}
Aliquam lectus. Vivamus leo. Quisque ornare tellus ullamcorper nulla. 
Mauris porttitor haretra tortor. So it is a \inlinestructure following text. Aliquam lectus. Vivamus leo. 
Quisque ornare tellus ullamcorper nulla. Mauris porttitor haretra tortor
\end{document}

在此处输入图片描述

相关内容