2

I am using Kile for a variety of projects and documents which are large. Therefore, I split the files into different *.tex files which are stored in different folders such as Chapters, Appendix, Pre and so on. As the \include{} statement makes some magic and produces for each file the *.auxfile, the live-preview does not work if the included texfiles are stored in subfolders. In order to enable the preview, the subfolders have to be created in the corresponding temporarykile live-preview folder. Using the latest beta version of kile (2.9.93), the data are located in the /tmp/kile-livepreview*folder.

1

As I want to share my solution, I will just do it here (hopefully at the right place) to support other people who might have a similar problem. Furthermore, the solution is build for a variety of LaTeXprojects, stored inside a user defined folder. The script is a bash function that can be included in the $HOME/.bash_functions file. Please change the searchProjects variable with your path

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 ""
}
1
0

Kile has "projects" which exist exactly for this reason (I suppose). To solve your issue create a project (from the top menu project > new) then add all your files to the project (you can do it from the top menu entry "project" or from the left panel "files and projects".

Then whatever chapter.tex you are working on, both live-preview and compile button will compile the main tex file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.