Skip to content

Instantly share code, notes, and snippets.

View jecs's full-sized avatar

José E. Cruz Serrallés jecs

  • New York University, Grossman School of Medicine
  • New York, NY
View GitHub Profile
@jecs
jecs / tikzscale-subcaption-label-workaround.md
Last active June 10, 2025 22:11
Using tikzscale package with pgfplots figure containing subcaptions and labels

Problem

The tikzscale package overloads the \includegraphics command, uses a bounding box to calculate the size of a pgfplots plot, and adjusts the size of the plot such that the target height and width are met, while preserving font sizes. This approach works well unless you have \subcaption{} and \label{} embedded in the figure, which results in multiply-defined labels.

Workaround

  1. Add the following code to your preamble. <unique name> should be replaced by an appropriate toggle name. \newtoggle should be repeated for every figure containing a plot, each with a unique name.
\usepackage{etoolbox}
\newtoggle{}
@jecs
jecs / disable-julia-vim-tab-to-spaces.md
Last active November 13, 2023 16:43
Disable tab-to-spaces when using julia-vim

Option

The option that lets you achieve this is let g:julia_set_indentation=0. You can place this in your .vimrc. You can find this option using :h julia-vim at the very bottom of the help page. Note that this goes against the Julia community's style guidelines.

Sample .vimrc

I use vim-plug to manage my addons. If you use another addon manager, then you might have to edit the beginning to suit your needs.

call plug#begin()
Plug 'JuliaEditorSupport/julia-vim'
call plug#end()
@jecs
jecs / matlab_desktop_resize_fix.md
Last active March 29, 2019 15:35
Fix for MATLAB R2018a error 'Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData'

The issue pops up when you resize the desktop, as is commonplace when you use VNC across multiple machines.

A good workaround for this issue is to install the latest Oracle Java 8.

Installing Oracle Java 8

If you are using Ubuntu, you can add the Oracle 8 ppa:

sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-installer