首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我需要将文本放在他们的图形/表格引用旁边。我的实际文本放在文档的末尾。如何使用perl实现?

我需要将文本放在他们的图形/表格引用旁边。我的实际文本放在文档的末尾。如何使用perl实现?
EN

Stack Overflow用户
提问于 2019-07-09 17:42:01
回答 1查看 41关注 0票数 0
代码语言:javascript
复制
%%Figure-9
\begin{figure}[t]
\figurebox{}{}{1}[fgene-10-00561-g009]
\caption{Ectopic expression of \textit{TaPP2C135} in 
\textit{Arabidopsis}. \textbf{(A)}~Expression levels of}
\end{figure}

需要将上面的数字文本放在段落的引文末尾,引文将在文本".... (\hyperrefF9{\textbf{ figure ~9}})中。“

好心帮助天才,我是初学者!

EN

回答 1

Stack Overflow用户

发布于 2019-07-09 19:26:56

在tex文件中,我们找不到具有简单逻辑的结尾段落。因此,我将该图放在了图引用的末尾。

代码语言:javascript
复制
use strict;
use warnings;

my $texcontent = ' Sample content...
Need to place the above figure text near to citation end of paragraph, Citation would be in text ".... (\hyperref[F9]{\textbf{Figure~1}})."

Need to place the above figure text near to citation end of paragraph, Citation would be in text ".... (\hyperref[F9]{\textbf{Figure~2}})."

Need to place the above figure text near to citation end of paragraph, Citation would be in text ".... (\hyperref[F9]{\textbf{Figure~9}})."

Need to place the above figure text near to citation end of paragraph, Citation would be in text ".... (\hyperref[F9]{\textbf{Figure~3}})."

%%Figure-1
\begin{figure}[t]
\figurebox{}{}{1}[fgene-10-00561-g009]
\caption{Ectopic expression of \textit{TaPP2C135} in 
\textit{Arabidopsis}. \textbf{(A)}~Expression levels of}
\end{figure}

%%Figure-2
\begin{figure}[t]
\figurebox{}{}{1}[fgene-10-00561-g009]
\caption{Ectopic expression of \textit{TaPP2C135} in 
\textit{Arabidopsis}. \textbf{(A)}~Expression levels of}
\end{figure}

%%Figure-3
\begin{figure}[t]
\figurebox{}{}{1}[fgene-10-00561-g009]
\caption{Ectopic expression of \textit{TaPP2C135} in 
\textit{Arabidopsis}. \textbf{(A)}~Expression levels of}
\end{figure}

';

my ($pre,$match,$post) = "";
while($texcontent=~m/\%\%(Figure\-(?:[\w]+))\n?\\begin\{(figure\*?)\}((?:(?!\\end\{\2\}).)*)\\end\{\2\}/gs)
{
    $pre = $pre.$`; $match = $&; $post = $'; (my $figId = $1)=~s/\-/\~/i; #%%Figure-1 replaced with Figure~1

    if($pre=~m/$figId\}\}\)/i) #Searching the ID
    {
        $match=~s/\{figure/\{completedfigure/i; #Completed the figures changed to completedfigures.
        $pre=~s/$figId\}\}\)/$&\n<figplacedhere>$match<figplacedhere>/i; #TAG Placed figures identification 
        $match = "";
    }

    $pre = $pre.$match; $texcontent = $post;
}

if(length $pre) {  $texcontent = $pre.$post;  }

$texcontent=~s/<figplacedhere>//g; $texcontent=~s/\{completedfigure/\{figure/g;

print "--\n$texcontent\n--\n";

完全基于你的输入,我已经更新了代码,除非直到样本输入不同,否则代码不能工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56949723

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档