Hiển thị các bài đăng có nhãn Macro_Script. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Macro_Script. Hiển thị tất cả bài đăng

Thứ Ba, 16 tháng 6, 2026

Thứ Tư, 23 tháng 7, 2025

Nom Na Tong

Render font Nom Na Tong

\documentclass[11pt]{article}
\usepackage{fontspec}
\setmainfont{NomNaTong-Regular}
\usepackage{luacode}
\usepackage{longtable,array,xcolor,listings}
\begin{luacode*} 
function print_glyphs(maxCols,maxChars) 
  local id = font.current()         -- get Font ID
  local fnt = font.getfont(id)
  local col = 1
  local maxU4 = 15*(16^3+16^2+16+1)
  a = {}
  for k, v in pairs(fnt.characters) do
    a [#a + 1] = k
  end
  table.sort(a)
  for i, k in ipairs(a) do
    if i >= maxChars then break end
    if col == 1 then
      if k > maxU4 then
        tex.sprint(string.format("U+%06x", k))
      else
        tex.sprint(string.format("U+%04x", k))
      end
      tex.sprint("&") 
    end
    if (i) then
      tex.sprint(string.format([[\char%i]], k))
    else
     tex.sprint("~")
    end
    if col == maxCols then              -- Line finished?
      tex.sprint([[\\\cline{2-]] .. maxCols+1 .. "} ")  -- Yes
      col = 1                           -- newline
    else
      tex.sprint("&")                   -- no, Print &
      col = col + 1                     -- next column
    end
  end
end
\end{luacode*}


\begin{document}

\color{black!20}

\begin{longtable}{>{\color{black!50}\ttfamily\footnotesize}r|
                  *{10}{>{\color{black}}p{1.5em}|}}
\cline{2-11}
\endhead


\directlua{print_glyphs(10,65463)} \\ \cline{2-11}
\end{longtable}

\end{document}

Tách một file pdf gồm 90 trang ra 90 file pdf

Công việc này thực hiện trên MacBook
  1. Cài đặt công cụ (nếu chưa có):
    sudo apt-get install poppler-utils # Ubuntu/Debian brew install poppler # macOS

     

  2. Tạo script split_pdf.sh:
    #!/bin/bash input_pdf="input.pdf" # Thay tên file PDF gốc output_prefix="page" # Tiền tố tên file output # Tách từng trang thành file riêng pdfseparate "$input_pdf" "${output_prefix}_%d.pdf"

     

  3. Chạy script:
    chmod +x split_pdf.sh ./split_pdf.sh

     

Kết quả: page_1.pdf, page_2.pdf, ..., page_90.pdf

 

Thứ Bảy, 7 tháng 10, 2023

Các scripts hữu ích




    Trong Texmaker đôi khi ta copy một đoạn văn bản từ nơi khác vào và nếu ta muốn chuyển đoạn văn bản này sang Uppercase (toàn chữ in hoa) hay Lowercase (toàn chữ viết thường), ngoài phương pháp dùng macro truyền thống của $\rm \LaTeX$, ta có thể dùng script để chuyển case. Thầy Sơn sẽ hướng dẫn cách sử dụng script, còn dưới đây là code của các script đó.



  1. to uppercase
    var txt = TM.selection; 
    if (txt != "") {
    var pos = TM.selectionStart; 
    txt = txt.toUpperCase(); 
    TM.insertText(txt); 
    TM.selectRange(pos, txt.length); 
    }
    
  2. to lowercase
    var txt = TM.selection; 
    if (txt != "") {
    var pos = TM.selectionStart; 
    txt = txt.toLowerCase(); 
    TM.insertText(txt); 
    TM.selectRange(pos, txt.length); 
    }