使用 \include{} 进行 Kile 实时预览

使用 \include{} 进行 Kile 实时预览

我正在使用 Kile 处理各种大型项目和文档。因此,我将文件拆分成不同的文件,*.tex并存储在不同的文件夹中,例如Chapters、等等。由于语句会产生一些神奇的效果并为每个文件生成文件,因此如果包含的文件存储在子文件夹中,实时预览将不起作用。为了启用预览,必须在相应的kile 实时预览文件夹中创建子文件夹。使用最新的 kile 测试版 (2.9.93),数据位于文件夹中。AppendixPre\include{}*.auxtextemporary/tmp/kile-livepreview*

答案1

Kile 有“项目”,它们正是出于这个原因而存在的(我想)。要解决您的问题,请创建一个项目(从顶部菜单项目 > 新建),然后将所有文件添加到项目中(您可以从顶部菜单项“项目”或左侧面板“文件和项目”中执行此操作)。

然后,无论您正在处理哪个 chapter.tex,实时预览和编译按钮都会编译主 tex 文件。

答案2

因为我想分享我的解决方案,所以我将在这里分享(希望是在正确的地方),以支持其他可能遇到类似问题的人。此外,该解决方案是为各种LaTeX项目构建的,存储在用户定义的文件夹中。该脚本是一个可以包含在文件中的 bash 函数$HOME/.bash_functions。请使用searchProjects您的路径更改变量

function startKile
{
if [ -z "$1" ]
then
    echo "No LaTeX Project specified"
    availableProjects
    return
fi

num=0
project=""
searchProjects="$HOME/NAS/Business/OpenFOAM/LaTeX/*"

for d in `ls -d $searchProjects`
do
    # Does Project exist
    projectNum=`echo $d | grep -i "$1" | wc -l`

    # If yes set the project folder
    # If more found it is always the last one but we quit anyway
    if [ $projectNum -eq 1 ]
    then
        project=$d
    fi

    # Increase the found project folders
    num=$((num+$projectNum))
done

# If no project found, stop
if [ $num -eq 0 ]
then
    echo "No project found named: $1"
    availableProjects
    return

# If more than 1 project found, stop
elif [ $num != 1 ]
then
    echo "More than one project found: $1"

    for d in `ls -d $searchProjects`
    do
        echo $d | grep -i "$1"
    done
    return
else
    echo "Starting LaTeX project $project"
fi

startDir=`pwd`

# Clear live preview folder
liveDir="/tmp/"

rm -rf $liveDir/kile*
sleep 0.1

fileName=`ls $project/*.tex`

kile $fileName & generateFolders $liveDir $project

wait

#sentFiles $project
cd $startDir
}

function generateFolders
{
echo "Generate Folders for live preview"
sleep 2
cd $1
currLiveDir=""
i=0

# Run till kile stops
while true
do
    kileRunNum=`pstree -a | grep 'kile' | wc -l`

    # Less than 1 means no kile running
    if [ $kileRunNum -lt 2 ]
    then
        break
    fi

    if [ ! -d "$currLiveDir" ]
    then

        echo "Attempt $i"
        i=$((i+1))

        # Search the live-preview-folder
        for d in `ls kile-live* -d 2>/dev/null`
        do
            if [ -d "$d" ]
            then
                echo "Folder is -> $d"
                currLiveDir=$d
                cd $d

                # Get the project folders ($2) and build those in the
                # live preview one
                for build in `ls $2/* -d`
                do
                    if [ -d $build ]
                    then
                        fold=`echo $build | sed "s|$2/||"`
                        mkdir $fold
                    fi
                done
                cd $1
            fi
            echo "Folders generated ... "
        done
    else
        sleep 5
        echo -n "."
    fi

    sleep 1

done
}

function availableProjects ()
{
echo "--------------------------------------------"
echo "Available projects are:"
for d in `ls -d $HOME/NAS/Business/OpenFOAM/LaTeX/*`
do
k=`echo $d | cut -d'/' -f8`
    echo "--> $k"
done
echo "--------------------------------------------"
echo ""
}

相关内容