PatchKnitrSynctex
code to patch the Synctex file for use with knitr (similar to patchDVI for sweave)
Install / Use
/learn @jan-glx/PatchKnitrSynctexREADME
[DEPRECATED] patchKintrSynctex NOTE: Active Development for this function has moved to the patchSynctex package (CRAN) at Emmanuel Charpentiers Repository
You will however still find here an much faster but undocumented c++ version of the function.
patchKintrSynctex
code to patch the Synctex file for use with knitr (similar to patchDVI for sweave)
Usage
Save patchKnitrSynctex.R anywhere on your PC.
source() in every R Session.
Use patchKnitrSynctex("pathto/yourmaintexfile.tex") to patch the yourmaintexfile.synctex[.gz] after compilation.
Enjoy forward and reverse search with your favourite pdf viewer/Latex/Knitr Editor!
Example
For example using StatET with eclipse add a external build configuration (Sweave document Processing) and use 'Run commands in active R Console' with...
require(knitr);
opts_knit$set(concordance = TRUE);
texfile <- knit("${resource_loc:${source_file_path}}", encoding="UTF-8")
...in the sweave tab and...
syntex <- if (opts_knit$get('concordance'))"-synctex=1" else "-synctex=0";
command=paste("latexmk -pdf", syntex, "-interaction=nonstopmode", shQuote(texfile));
print(paste("Command ",command,"...\n"));
print(shell(command),intern = TRUE);
if (opts_knit$get('concordance')){
source("C:/Users/Jan/Documents/New folder/patchKnitrSynctex/patchKnitrSynctex.R", echo=FALSE, encoding="UTF-8");
patchSynctex(texfile);
}
print(paste0(substr(texfile,1, nchar(texfile)-3), "pdf"))
...in the Latex tab.
Remarks
This will break the Byte offsets in the sy This R implementation is not optimal. If you are compiling books this may slow down your compile process noticeable.
Acknowledgement
Code was inspired by patchDVI, RStudio and Synctex code. I am not affiliated with StatET, Eclipse, Knitr, RStudio, Synctex or patchDVI. They did all the work !
Related Skills
node-connect
352.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
