perl - 我需要将文本放在他们的图形/表格引用附近。我的实际文本放在文档末尾。使用perl如何实现?
问题描述
%%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}
需要将上图文本放置在段落的引用末尾附近,引用将在文本“.... (\hyperref[F9]{\textbf{Figure~9}})”中。
请帮助天才,我是初学者!
解决方案
在 tex 文件中,我们找不到具有简单逻辑的结尾段落。因此,我将图形放在图形引用的末尾。
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";
纯粹根据您的输入,我已经更新了代码,除非样本输入不同,否则代码可能不起作用。
推荐阅读
- python - AttributeError:模块'cv2'没有属性'face'(OpenCV和Python)
- c# - RoutePrefix 不同于控制器名称不起作用
- java - 使用 org.springframework.jndi.JndiObjectFactoryBean 作为连接工厂
- c++ - 使用带有字符串参数的函数进行输入验证
- php - PHP 致命错误:未捕获的 HY000:“自适应服务器连接超时”
- azure - 使用单个 Azure 函数代表他们访问多个用户的资源
- java - Java - 仅在初始窗口内重新绘制图形
- sql - 如何使用 SQL Server 2016 将以下文本字符串转换为日期类型
- reactjs - 基于另一个字段的值所需的字段 - formik,是的
- android - 如何为 Android SearchView 创建自定义样式?