zoukankan      html  css  js  c++  java
  • LaTex Tricks

    TeXstudio has the Ctrl+T/U shortcuts for commenting/uncommenting multilines.

    Comment in pseudocodes (Just for use with package algorithmic. For algorithmicx, simply use Comment{})

    documentclass{article}
    usepackage{algorithm,algorithmic}
    usepackage{eqparbox}
    %
    enewcommand{algorithmiccomment}[1]{hfilleqparbox{COMMENT}{# #1}}
    
    enewcommand{algorithmiccomment}[1]{hfilleqparbox{COMMENT}{/* #1 */}}
    egin{document}
    	egin{algorithm}
    		egin{algorithmic}[1]
    			STATE $sum=0$;
    			FOR[comment for FOR]{$j=1$ TO $100$}
    			IF[comment for IF]{$j\%2==1$}
    			STATE $sum=sum+i$; COMMENT{normal comment}
    			ENDIF
    			ENDFOR
    		end{algorithmic}
    	end{algorithm}
    end{document}
    

     

    LaTex algorithm Packages (ACK:https://tex.stackexchange.com/questions/229355/algorithm-algorithmic-algorithmicx-algorithm2e-algpseudocode-confused)

    • algorithm - float wrapper for algorithms.
    • algorithmic - first algorithm typesetting environment.
    • algorithmicx - second algorithm typesetting environment.
    • algpseudocode - layout for algorithmicx.
    • algorithm2e - third algorithm typesetting environment.

    I use algorithmicx with algpseudocode since they are superior to algorithmic. I think algorithmicx offers the same functionality compared to algorithm2e, but I find its syntax clearer than the one provided by algorithm2e.

    Algorithm vs. Procedure (Ack https://qr.ae/pGOhuN)

    A procedure which always terminates is called an algorithm.

     

     The notion of a procedure and an algorithm is formally defined in the book “ Formal Languages and their relation to Automata “ (1969), by hopcroft and ullman. https://savedparadigms.files.wordpress.com/2014/09/formal-languages-and-their-relation-to-automata-john-e-hopcroft-jeffrey-d-ullman.pdf

  • 相关阅读:
    leetcode — spiral-matrix-ii
    leetcode — spiral-matrix
    leetcode — maximum-subarray
    leetcode — n-queens
    leetcode — powx-n
    leetcode — anagrams
    bzoj 2194: 快速傅立叶之二 FFT
    bzoj 4503 两个串 快速傅里叶变换FFT
    Codeforces 762D Maximum path 动态规划
    Codeforces 762C Two strings 字符串
  • 原文地址:https://www.cnblogs.com/cxxszz/p/12290893.html
Copyright © 2011-2022 走看看