Generalminted | copy/paste source codes with indent

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Tedd
Posts: 6
Joined: Wed Dec 19, 2012 3:33 am

minted | copy/paste source codes with indent

Post by Tedd »

Hello everybody again.

I wish could copy and paste source code of my PDFs.
But when i use the minted package, although indent correctly, i can't paste indented.

It is possible to make it copyable/pastable with indentation?

I know that changing these lines i can decide what will appear in place of the spaces, but how to make it work properly?

Code: Select all

\define@booleankey{FV}{showspaces}%
{\def\FV@Space{{\FancyVerbSpace}}}%
{\def\FV@Space{\ }}
Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

minted | copy/paste source codes with indent

Post by cgnieder »

Could you please make a complete Infominimal working example explaining what you are doing and what you are trying to achieve?

Regards
site moderator & package author
Tedd
Posts: 6
Joined: Wed Dec 19, 2012 3:33 am

minted | copy/paste source codes with indent

Post by Tedd »

Hello again cgnieder.

Yes, i can! I summarized my entire code for these lines:

Code: Select all

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{minted}

%################################
% Adjustments the numbers to copy
%################################

% from http://tex.stackexchange.com/questions/57151/how-do-i-prevent-conflicts-between-accsupp-and-hyperref
\usepackage{accsupp}
\newcommand\emptyaccsupp[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}

%default definition is: \def\theFancyVerbLine{\rmfamily\tiny\arabic{FancyVerbLine}}
\let\theHFancyVerbLine\theFancyVerbLine% don't apply our patch to hyperref's version
\def\theFancyVerbLine{\rmfamily\tiny\emptyaccsupp{\arabic{FancyVerbLine}}}

%################################

\newminted{ruby}{fontfamily=courier,fontsize=\scriptsize,frame=single,linenos=true,framesep=2mm,showspaces=false}

\begin{document}

\begin{rubycode}

#==============================================================================
# ** Vocab
#------------------------------------------------------------------------------
#  This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================
 
module Vocab
 
  # Shop Screen
  ShopBuy         = "Buy"
  ShopSell        = "Sell"
  ShopCancel      = "Cancel"
  Possession      = "Possession"
 
  # Status Screen
  ExpTotal        = "Current Exp"
  ExpNext         = "To Next %s"

  # Level
  def self.level
    return $data_system.terms.level
  end
 
  # Level (Abbreviation)
  def self.level_a
    return $data_system.terms.level_a
  end

end

\end{rubycode}

\end{document}
So when i copy this code, i want it to come like this:

Code: Select all

module Vocab
 
  # Shop Screen
  ShopBuy         = "Buy"
  ShopSell        = "Sell"
  ShopCancel      = "Cancel"
  Possession      = "Possession"
 
  # Status Screen
  ExpTotal        = "Current Exp"
  ExpNext         = "To Next %s"

  # Level
  def self.level
    return $data_system.terms.level
  end
 
  # Level (Abbreviation)
  def self.level_a
    return $data_system.terms.level_a
  end

end
But when I pasted it, looks like this:

Code: Select all

#==============================================================================
# ** Vocab
#------------------------------------------------------------------------------
# This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================
module Vocab
# Shop Screen
ShopBuy
ShopSell
ShopCancel
Possession
=
=
=
=
"Buy"
"Sell"
"Cancel"
"Possession"
# Status Screen
ExpTotal
= "Current Exp"
ExpNext
= "To Next %s"
# Level
def self.level
return $data_system.terms.level
end
# Level (Abbreviation)
def self.level_a
return $data_system.terms.level_a
end
end
Thankful.

Ps: I use Lyx.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: minted | copy/paste source codes with indent

Post by cgnieder »

I found one similar post asking the same thing (http://tex.stackexchange.com/questions/ ... d-copyable) but I unfortunately without an answer (and I suspect you know that post already). I'm afraid I have no idea how to do that. Hopefully someone else will.

Regards
site moderator & package author
Tedd
Posts: 6
Joined: Wed Dec 19, 2012 3:33 am

minted | copy/paste source codes with indent

Post by Tedd »

Oh yes, i read it but no solution...
So hopefully someone help. Thank you again cgnieder!

Waiting.
Post Reply