latex update
This commit is contained in:
@@ -2656,15 +2656,55 @@ class Production extends Base
|
||||
$citationKey = 'ref_' . $ref['p_refer_id'];
|
||||
|
||||
// 如果有解析后的作者和标题信息,优先使用
|
||||
if (!empty($ref['author']) && !empty($ref['title'])) {
|
||||
// if (!empty($ref['author']) && !empty($ref['title'])) {
|
||||
if ($ref['refer_type'] == "journal") {
|
||||
return $this->generateFromParsedData($ref, $citationKey);
|
||||
} // 否则尝试从原始内容解析
|
||||
else {
|
||||
return;
|
||||
// return $this->generateFromRawContent($ref, $citationKey);
|
||||
} elseif ($ref['refer_type'] == "book"){
|
||||
|
||||
} else {
|
||||
return $this->generateOtherMsic($ref, $citationKey);
|
||||
}
|
||||
}
|
||||
|
||||
private function generateOtherBook($ref, $citationKey){
|
||||
$entry = "@book{{$citationKey},\n";
|
||||
|
||||
// 添加基本字段
|
||||
if (!empty($ref['author'])) {
|
||||
$entry .= " author={" . $this->escapeBibTeX($this->formatBibTeXAuthors($ref['author'])) . "},\n";
|
||||
}
|
||||
|
||||
if (!empty($ref['title'])) {
|
||||
$entry .= " title={" . $this->escapeBibTeX($ref['title']) . "},\n";
|
||||
}
|
||||
|
||||
if (!empty($ref['publisher'])) {
|
||||
$entry .= " publisher={" . $this->escapeBibTeX($ref['dateno']) . "},\n";
|
||||
}
|
||||
|
||||
|
||||
// 移除最后一个逗号并关闭条目
|
||||
$entry = rtrim($entry, ",\n") . "\n}";
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
|
||||
private function generateOtherMsic($ref, $citationKey){
|
||||
|
||||
$entry = "@misc{{$citationKey},\n";
|
||||
|
||||
if (!empty($ref['title'])) {
|
||||
$entry .= " title={" . $this->escapeBibTeX($ref['title']) . "},\n";
|
||||
}else{
|
||||
$entry .= " title={" . $this->escapeBibTeX($ref['refer_frag']) . "},\n";
|
||||
}
|
||||
// 移除最后一个逗号并关闭条目
|
||||
$entry = rtrim($entry, ",\n") . "\n}";
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
|
||||
private function parsePublicationInfo($referenceText)
|
||||
{
|
||||
@@ -3395,12 +3435,22 @@ class Production extends Base
|
||||
$latex[] = "\\begin{".$table_ss."}{".$this->convertToLatex($title,$references)."}{".$label."}{".$columnSpec."}{1}{".$notes."}";
|
||||
|
||||
// 遍历表格数据,生成每一行
|
||||
$table = [];
|
||||
foreach ($tableData as $rowIndex => $row) {
|
||||
$cells = [];
|
||||
// $cells = [];
|
||||
$table[$rowIndex] = [];
|
||||
$currentCol = 0; // 记录当前处理到的列位置
|
||||
|
||||
//调整$currentCol
|
||||
// while (isset($table[$rowIndex][$currentCol])){
|
||||
// $currentCol += 1;
|
||||
// }
|
||||
|
||||
// 处理当前行的每个单元格
|
||||
foreach ($row as $cell) {
|
||||
while (isset($table[$rowIndex][$currentCol])){
|
||||
$currentCol += 1;
|
||||
}
|
||||
// 处理单元格文本:移除HTML标签,替换为LaTeX粗体
|
||||
$text = $this->convertToLatex($cell['text'], $references);
|
||||
|
||||
@@ -3414,25 +3464,50 @@ class Production extends Base
|
||||
if ($colspan > 1 && $rowspan > 1) {
|
||||
// 跨行跨列
|
||||
$cellContent = "\\SetCell[c={$colspan},r={$rowspan}]{l,bg=white} {$cellContent}";
|
||||
$table[$rowIndex][$currentCol] = $cellContent;
|
||||
for($n_c=1;$n_c<$colspan;$n_c++){
|
||||
$table[$rowIndex][$currentCol+$n_c] = "";
|
||||
}
|
||||
for ($a_r=1;$a_r<$rowspan;$a_r++){
|
||||
for ($a_c=0;$a_c<$colspan;$a_c++){
|
||||
$table[$rowIndex+$a_r][$currentCol+$a_c] = "";
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ($colspan > 1) {
|
||||
// 仅跨列
|
||||
$cellContent = "\\SetCell[c={$colspan}]{l,bg=white} {$cellContent}";
|
||||
$table[$rowIndex][$currentCol] = $cellContent;
|
||||
for($n_c=1;$n_c<$colspan;$n_c++){
|
||||
$table[$rowIndex][$currentCol+$n_c] = "";
|
||||
}
|
||||
} elseif ($rowspan > 1) {
|
||||
// 仅跨行
|
||||
$cellContent = "\\SetCell[r={$rowspan}]{l,bg=white} {$cellContent}";
|
||||
$table[$rowIndex][$currentCol] = $cellContent;
|
||||
for ($a_r=1;$a_r<$rowspan;$a_r++){
|
||||
$table[$rowIndex+$a_r][$currentCol] = "";
|
||||
}
|
||||
}
|
||||
|
||||
$cells[] = $cellContent;
|
||||
// $cells[] = $cellContent;
|
||||
|
||||
// 如果是跨列单元格,跳过后续的colspan-1个位置
|
||||
$currentCol += $colspan;
|
||||
}
|
||||
|
||||
// 拼接单元格,行尾用\\
|
||||
$rowContent = implode(' & ', $cells) . " \\\\";
|
||||
// $rowContent = implode(' & ', $cells) . " \\\\";
|
||||
// $latex[] = " {$rowContent}";
|
||||
}
|
||||
|
||||
|
||||
foreach ($table as $row){
|
||||
$rowContent = implode(' & ', $row) . " \\\\";
|
||||
$latex[] = " {$rowContent}";
|
||||
}
|
||||
|
||||
|
||||
$latex[] = "\\end{".$table_ss."}";
|
||||
|
||||
// 拼接所有行,返回LaTeX代码
|
||||
|
||||
Reference in New Issue
Block a user