5

I'm preparing tutorial for students with code fragments that they will copy to a text editor.

Is there a way to make syntax-highlighted code copyable to text editor so that indentation is preserved, when indenting with tabs?

I was able to achieve this with space-indented code, using this answer: https://tex.stackexchange.com/a/148661/16951

So I tried to do the same with tabs, so change the visible tab character to normal tab, but I don't know what is the visible tab character code. It seems it's not a single character, because when I copy it, I get i | in text editor.

Is there a way to add copyable invisible tabs to minted-coloured code?

Here is my minimal example (the HTML code is indented with tabs, but I think it's not preserved when SE question is rendered):

\documentclass[10pt, a4paper, oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{polski, indentfirst}
\usepackage[polish]{babel}
\usepackage{minted}

\usepackage{environ}
\usepackage{xparse}


\NewDocumentEnvironment {codehtml} {}
{\VerbatimEnvironment
\begin{minted}[tabsize=4, obeytabs, showtabs]{html}}
{\end{minted}}

\begin{document}

\begin{codehtml}
<!DOCTYPE html>
<html lang="pl">
    <head>
        <meta charset="utf-8">
        <title>Formularz</title>
    </head>
\end{codehtml}

\end{document}

Your Answer

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

Browse other questions tagged or ask your own question.