排版调整

This commit is contained in:
chengxl
2026-02-14 14:00:05 +08:00
parent f17c1e2308
commit 85ae4aeffd

View File

@@ -52,6 +52,7 @@ page={{stage_page}},%号
\usepackage{tabularray} \usepackage{tabularray}
\addbibresource{references_{{article_id}}.bib} \addbibresource{references_{{article_id}}.bib}
\definecolor{evenRowColor}{RGB}{250,231,232} \definecolor{evenRowColor}{RGB}{250,231,232}
\SetLeftRatio{{{left_ratio}}}
\setlength{\parindent}{1em} \setlength{\parindent}{1em}
\title{{{article_title}}} \title{{{article_title}}}
@@ -230,6 +231,10 @@ page={{stage_page}},%号
$aSearch['{{keywords}}'] = $sKeywords; $aSearch['{{keywords}}'] = $sKeywords;
// $aSearch['{{CLSFILEURL}}'] = ROOT_PATH.'public/latex/cls'; // $aSearch['{{CLSFILEURL}}'] = ROOT_PATH.'public/latex/cls';
$aSearch['{{article_id}}'] = $aProductionArticle['article_id']; $aSearch['{{article_id}}'] = $aProductionArticle['article_id'];
$aSearch['is_have_icon'] = empty($sIcon) ? 2 : 1;
//计算左侧内容长度
$aRatio = $this->generateLatexDynamicColumns($aSearch);
$aSearch['{{left_ratio}}'] = empty($aRatio['left_ratio']) ? '' : $aRatio['left_ratio'];
//模版内容替换 //模版内容替换
$sTemplateInfo = str_replace(array_keys($aSearch), array_values($aSearch), $sTemplateInfo); $sTemplateInfo = str_replace(array_keys($aSearch), array_values($aSearch), $sTemplateInfo);
//返回内容 //返回内容
@@ -712,6 +717,97 @@ page={{stage_page}},%号
return ['status' => 1,'msg' => 'success','data' => implode("\n", $latexLines)]; return ['status' => 1,'msg' => 'success','data' => implode("\n", $latexLines)];
} }
/**
* 动态LaTeX 比例分栏[两栏]
*/
private function generateLatexDynamicColumns($aSearch = []) {
//数据处理
//右侧列
$sRightLen = '';
if(!empty($aSearch['{{abstract}}'])){
$sRightLen .= $aSearch['{{abstract}}'];
}
if(!empty($aSearch['{{keywords}}'])){
$sRightLen .= $aSearch['{{keywords}}'];
}
$iRightLen = mb_strlen($sRightLen, 'UTF-8');
if(!empty($aSearch['is_have_icon']) && $aSearch['is_have_icon'] == 1){
$iRightImgRatio = 0.6; // 图片宽度=0.6\textwidth
$iRightImgChar = $this->imgRatioToCharCount($iRightImgRatio);
$iRightLen = $iRightLen + $iRightImgChar;
}
//左侧列
$sLefttLen = '';
if(!empty($aSearch['{{author_contribution}}'])){
$sLefttLen .= 'Author contributions'."\n".$aSearch['{{author_contribution}}'];
}
$sLefttLen .= 'Competing interests'."\n".'The authors declare no conflicts of interest.';
if(!empty($aSearch['{{article_acknowledgment}}'])){
$sLefttLen .= 'Acknowledgments'."\n".$aSearch['{{article_acknowledgment}}'];
}
if(!empty($aSearch['{{article_abbreviation}}'])){
$sLefttLen .= 'Abbreviations'."\n".$aSearch['{{article_abbreviation}}'];
}
if(!empty($aSearch['{{article_cite}}'])){
$sLefttLen .= 'Citation'."\n".$aSearch['{{article_cite}}'];
}
if(!empty($aSearch['{{journal_title}}'])){
$sLefttLen .= 'Peer review information'."\n".$aSearch['{{journal_title}}'].' thanks all anonymous reviewers for their contribution to the peer review of this paper';
}
if(!empty($aSearch['{{editorial_advisory_board}}'])){
$sLefttLen .= 'Editorial Advisory Board: '.$aSearch['{{editorial_advisory_board}}'];
}
if(!empty($aSearch['{{executive_editor}}'])){
$sLefttLen .= 'Executive editor: '.$aSearch['{{executive_editor}}'];
}
if(!empty($aSearch['{{received_date}}'])){
$sLefttLen .= 'Received: '.$aSearch['{{received_date}}'].'; ';
}
if(!empty($aSearch['{{revision_date}}'])){
$sLefttLen .= 'Revised: '.$aSearch['{{revision_date}}'].'; ';
}
if(!empty($aSearch['{{accepted_date}}'])){
$sLefttLen .= 'Accepted:'.$aSearch['{{accepted_date}}'].'; ';
}
if(!empty($aSearch['{{pub_date}}'])){
$sLefttLen .= 'Available online: '.$aSearch['{{pub_date}}'];
}
$sLefttLen .= date('Y').' By Author(s). Published by TMR Publishing Group Limited. This is an open access article under the CC-BY license. (https://creativecommons.org/licenses/by/4.0/)';
$iLeftLen = mb_strlen($sLefttLen, 'UTF-8');
//统计总字数
$iTotalLen = $iLeftLen + $iRightLen;
$iLeftRatio = $iRightRatio = 0.5;
if($iTotalLen > 0) {
$iLeftRatio = round($iLeftLen / $iTotalLen,2);
}
if(intval($iLeftRatio*100) > 50){
$iLeftRatio = 0.5;
}
if(intval($iLeftRatio*100) < 36){
$iLeftRatio = 0.36;
}
return ['left_ratio' => $iLeftRatio];
}
/**
* 图片宽度比例 → 等效英文字符数
* @param float $fImgRatio 图片宽度占\textwidth的比例如0.5=0.5\textwidth
* @param float $fTextWidthEm 页面\textwidth的em宽度英文期刊默认36em
* @return int 英文字符数
*/
function imgRatioToCharCount($fImgRatio = 0.6, $fTextWidthEm = 36) {
if ($fImgRatio <= 0 || !is_numeric($fImgRatio)) {
return 0;
}
//计算图片宽度em
$fImgWidthEm = $fImgRatio * $fTextWidthEm;
//折算为英文字符数1em=2个英文字符
$iImgCharCount = round($fImgWidthEm * 2);
return max($iImgCharCount, 0);
}
} }
?> ?>