<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/miktex-behind-a-windows-firewall/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://adamleerich.github.io/2018/07/21/miktex-install.html"> TeachR</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I’ve always had problems with MiKTeX on my work computer.<br>
I can install it just fine, or get IT to install it, but then the package manager doesn’t work because of our firewall.<br>
You can set up a local repository to get around this problem, and I will show you how.<br>
I’m just doing a basic setup here, just enough to compile the RStudio Rmd template to PDF.</p>
<p>“Why do I need MiKTeX?”, you might ask.<br>
Well, because if you want to create a PDF from an RMarkdown file in RStudio it is required.<br>
Otherwise you get this polite error message.</p>
<p><img alt="RStudio: No pdflatex error message" src="https://i2.wp.com/adamleerich.github.io/assets/MiKTeX/no-pdflatex-error.png?w=456" data-recalc-dims="1"></p>
<p>I downloaded the 32-bit basic version from <a rel="nofollow" href="https://miktex.org/download" target="_blank">https://MiKTeX.org/download</a>.</p>
<p><img alt="MiKTeX Basic 32-bit Download" src="https://i0.wp.com/adamleerich.github.io/assets/MiKTeX/miktex-basic-32-download.png?w=456" data-recalc-dims="1"></p>
<p>You’ll probably just want to pick the default options for the install EXCEPT for<br>
the question that asks whether you want MiKTeX to install missing packages automatically.<br>
I’m saying “no” to that because that is where the firewall gets in the way.</p>
<p><img src="https://i0.wp.com/adamleerich.github.io/assets/MiKTeX/miktex-install-missing-prompt.png?w=456" alt="Say " data-recalc-dims="1"></p>
<p>MiKTeX will update your <code>PATH</code> system variable, but to get RStudio to recognize that it has changed you will need to restart it.<br>
Trying to knit the RStudio Rmd template to PDF right after install gives a new error, that it cannot find the file “url.sty”.<br>
Actually, if you had done the default install, MiKTeX would have tried to install the needed package automatically.<br>
But, this would have just failed if the needed port is not open on your firewall.</p>
<p>One way to get the packages you need is to create a local package repo and install the packages “manually”.</p>
<p>I’ve created a github repo with a minimal set of LaTeX packages to get this working,<br>
<a rel="nofollow" href="https://github.com/adamleerich/MiKTeX_pkgs" target="_blank">https://github.com/adamleerich/MiKTeX_pkgs</a>.<br>
So, you can clone it straight, download a ZIP, or fork and clone. Up to you.<br>
I’m going to assume you know how to get these files from github and put them somewhere inside your firewall.<br>
I’ve put mine in a folder called <code>c:\home\git\Other\MiKTeX_pkgs</code>.</p>
<p>Next, open the MiKTeX package manager on your computer.<br>
It was just installed.<br>
Select change package repository from the repository menu.<br>
It will then ask you what kind of repo you want.</p>
<p><img alt="You want a local repo" src="https://i1.wp.com/adamleerich.github.io/assets/MiKTeX/miktex-change-pkg-dir.png?w=456" data-recalc-dims="1"></p>
<p>On the next screen browse to the folder where you cloned the git repo, and point to the “repo-local” subdirectory.</p>
<p><img alt="You can send me an email if I've lost you" src="https://i1.wp.com/adamleerich.github.io/assets/MiKTeX/miktex-new-pkg-dir.png?w=456" data-recalc-dims="1"></p>
<p>MiKTeX will take <em>forever</em> to synchronize the package database, but once it is done, you can select the packages you want installed.<br>
Unfortunately, I have not been able to figure out how to create an index file that just has the downloaded packages in it.<br>
So, the package manager will still list all of the packages available at the CTAN mirror.<br>
I know, it sucks.<br>
Then you can run the batch file <code>scripts\100-mpm-install.bat</code> as an admin and it will install the packages for you.</p>
<p>If you decide you want to add more packages to your local repo, just put the file name in the DOWNLOAD file<br>
and re-run the script <code>./scripts/050-download-locals.bat</code> and then <code>scripts\100-mpm-install.bat</code>.</p>
<p>Let me know if this helps or if it doesn’t work for you.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://adamleerich.github.io/2018/07/21/miktex-install.html"> TeachR</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/_HqtYvy0UG4" height="1"></a></div>