diff --git a/.gitignore b/.gitignore index d5428302..ec1a0a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -250,11 +250,5 @@ ehthumbs_vista.db [Dd]esktop.ini # Project specific -release/* -sample/*.pdf -*.cls -*.ins -*.ltx -sjtuthesis.pdf thesis.pdf thesis-bot.yml diff --git a/source/latexmkrc.pl b/.latexmkrc similarity index 54% rename from source/latexmkrc.pl rename to .latexmkrc index 536b6955..6e44edc1 100644 --- a/source/latexmkrc.pl +++ b/.latexmkrc @@ -9,12 +9,3 @@ # Files to clean. $clean_ext = 'bbl glo gls hd loa run.xml thm xdv'; - -# Process index. -$makeindex = 'makeindex -s gind.ist %O -o %D %S'; - -# Process glossary (change history). -add_cus_dep('glo', 'gls', 0, 'makeglo2gls'); -sub makeglo2gls { - system("makeindex -q -s gglo.ist -o '$_[0].gls' '$_[0].glo'"); -} diff --git a/.travis.yml b/.travis.yml index c336872b..692d7cc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,11 +15,10 @@ matrix: - $HOME/.miktex before_script: - - source scripts/unpack.sh - - sed -i 's/documentclass\[/documentclass[fontset=fandol, /' sample/thesis.tex + - sed -i 's/documentclass\[/documentclass[fontset=fandol, /' thesis.tex script: - - latexmk -cd -quiet -halt-on-error -time -xelatex sample/thesis.tex + - latexmk -quiet -halt-on-error -time -xelatex thesis.tex after_failure: - - cat sample/thesis.log + - cat thesis.log diff --git a/source/sample.bat b/Compile.bat similarity index 91% rename from source/sample.bat rename to Compile.bat index 64124c0f..8b556743 100644 --- a/source/sample.bat +++ b/Compile.bat @@ -1,105 +1,105 @@ -@echo off -chcp 65001 >nul - -set THESIS=thesis - -set flag=%1 -if %flag%x == x ( - set flag=thesis -) - -if %flag%x == thesisx ( - call :cleanall - call :thesis - if ERRORLEVEL 1 ( - echo Error! Please check the 'thesis.log' for more details... - pause - ) else ( - call :clean - echo Finished! - ) - goto :EOF -) - -if %flag%x == cleanx ( - call :clean - goto :EOF -) - -if %flag%x == cleanallx ( - call :cleanall - goto :EOF -) - -if %flag%x == wordcountx ( - call :wordcount - goto :EOF -) - -:help - echo This is the compile batch script for SJTUThesis. - echo Usage: - echo compile.bat [option] - echo options: - echo thesis Compile the thesis (default) - echo clean Clean all work files - echo cleanall Clean all work files and thesis.pdf - echo wordcount Count words in thesis.pdf - echo help Print this help message -goto :EOF - -:thesis - echo Compile... - latexmk -xelatex -halt-on-error -silent thesis >nul 2>nul -goto :EOF - -:clean - echo Clean files... - latexmk -c -silent 2>nul - del tex\*.aux >nul 2>nul -goto :EOF - -:cleanall - echo Clean files... - latexmk -C -silent 2>nul - del tex\*.aux >nul 2>nul - if exist thesis.pdf ( - echo Close the file: thesis.pdf! - pause - call :cleanall - ) -goto :EOF - -:wordcount - set found=0 - setlocal enabledelayedexpansion - - findstr "\\documentclass\[[^\[]*english" %THESIS%.tex > nul - if %errorlevel% equ 0 ( - for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -char-only 2^>nul') do ( - if !found! equ 1 ( - echo 英文字符数: !%%i! - goto :total - ) - echo %%i | findstr "total" > nul && set found=1 - ) - ) else ( - for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -ch-only 2^>nul') do ( - if !found! equ 1 ( - echo 纯中文字数: !%%i! - goto :total - ) - echo %%i | findstr "total" > nul && set found=1 - ) - ) - -:total - set found=0 - for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -chinese 2^>nul') do ( - if !found! equ 1 ( - echo 总字数^(英文单词+中文字^):!%%i! - goto :EOF - ) - echo %%i | findstr "total" > nul && set found=1 - ) -goto :EOF \ No newline at end of file +@echo off +chcp 65001 >nul + +set THESIS=thesis + +set flag=%1 +if %flag%x == x ( + set flag=thesis +) + +if %flag%x == thesisx ( + call :cleanall + call :thesis + if ERRORLEVEL 1 ( + echo Error! Please check the 'thesis.log' for more details... + pause + ) else ( + call :clean + echo Finished! + ) + goto :EOF +) + +if %flag%x == cleanx ( + call :clean + goto :EOF +) + +if %flag%x == cleanallx ( + call :cleanall + goto :EOF +) + +if %flag%x == wordcountx ( + call :wordcount + goto :EOF +) + +:help + echo This is the compile batch script for SJTUThesis. + echo Usage: + echo compile.bat [option] + echo options: + echo thesis Compile the thesis (default) + echo clean Clean all work files + echo cleanall Clean all work files and thesis.pdf + echo wordcount Count words in thesis.pdf + echo help Print this help message +goto :EOF + +:thesis + echo Compile... + latexmk -xelatex -quiet -file-line-error -halt-on-error -interaction=nonstopmode thesis >nul 2>nul +goto :EOF + +:clean + echo Clean files... + latexmk -c -silent 2>nul + del tex\*.aux >nul 2>nul +goto :EOF + +:cleanall + echo Clean files... + latexmk -C -silent 2>nul + del tex\*.aux >nul 2>nul + if exist thesis.pdf ( + echo Close the file: thesis.pdf! + pause + call :cleanall + ) +goto :EOF + +:wordcount + set found=0 + setlocal enabledelayedexpansion + + findstr "\\documentclass\[[^\[]*english" %THESIS%.tex > nul + if %errorlevel% equ 0 ( + for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -char-only 2^>nul') do ( + if !found! equ 1 ( + echo 英文字符数: !%%i! + goto :total + ) + echo %%i | findstr "total" > nul && set found=1 + ) + ) else ( + for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -ch-only 2^>nul') do ( + if !found! equ 1 ( + echo 纯中文字数: !%%i! + goto :total + ) + echo %%i | findstr "total" > nul && set found=1 + ) + ) + +:total + set found=0 + for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -chinese 2^>nul') do ( + if !found! equ 1 ( + echo 总字数^(英文单词+中文字^):!%%i! + goto :EOF + ) + echo %%i | findstr "total" > nul && set found=1 + ) +goto :EOF diff --git a/LICENSE b/LICENSE index 22443139..8c4b8aa8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,416 +1,202 @@ -The LaTeX Project Public License -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -LPPL Version 1.3c 2008-05-04 - -Copyright 1999 2002-2008 LaTeX3 Project - Everyone is allowed to distribute verbatim copies of this - license document, but modification of it is not allowed. - - -PREAMBLE -======== - -The LaTeX Project Public License (LPPL) is the primary license under -which the LaTeX kernel and the base LaTeX packages are distributed. - -You may use this license for any work of which you hold the copyright -and which you wish to distribute. This license may be particularly -suitable if your work is TeX-related (such as a LaTeX package), but -it is written in such a way that you can use it even if your work is -unrelated to TeX. - -The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', -below, gives instructions, examples, and recommendations for authors -who are considering distributing their works under this license. - -This license gives conditions under which a work may be distributed -and modified, as well as conditions under which modified versions of -that work may be distributed. - -We, the LaTeX3 Project, believe that the conditions below give you -the freedom to make and distribute modified versions of your work -that conform with whatever technical specifications you wish while -maintaining the availability, integrity, and reliability of -that work. If you do not see how to achieve your goal while -meeting these conditions, then read the document `cfgguide.tex' -and `modguide.tex' in the base LaTeX distribution for suggestions. - - -DEFINITIONS -=========== - -In this license document the following terms are used: - - `Work' - Any work being distributed under this License. - - `Derived Work' - Any work that under any applicable law is derived from the Work. - - `Modification' - Any procedure that produces a Derived Work under any applicable - law -- for example, the production of a file containing an - original file associated with the Work or a significant portion of - such a file, either verbatim or with modifications and/or - translated into another language. - - `Modify' - To apply any procedure that produces a Derived Work under any - applicable law. - - `Distribution' - Making copies of the Work available from one person to another, in - whole or in part. Distribution includes (but is not limited to) - making any electronic components of the Work accessible by - file transfer protocols such as FTP or HTTP or by shared file - systems such as Sun's Network File System (NFS). - - `Compiled Work' - A version of the Work that has been processed into a form where it - is directly usable on a computer system. This processing may - include using installation facilities provided by the Work, - transformations of the Work, copying of components of the Work, or - other activities. Note that modification of any installation - facilities provided by the Work constitutes modification of the Work. - - `Current Maintainer' - A person or persons nominated as such within the Work. If there is - no such explicit nomination then it is the `Copyright Holder' under - any applicable law. - - `Base Interpreter' - A program or process that is normally needed for running or - interpreting a part or the whole of the Work. - - A Base Interpreter may depend on external components but these - are not considered part of the Base Interpreter provided that each - external component clearly identifies itself whenever it is used - interactively. Unless explicitly specified when applying the - license to the Work, the only applicable Base Interpreter is a - `LaTeX-Format' or in the case of files belonging to the - `LaTeX-format' a program implementing the `TeX language'. - - - -CONDITIONS ON DISTRIBUTION AND MODIFICATION -=========================================== - -1. Activities other than distribution and/or modification of the Work -are not covered by this license; they are outside its scope. In -particular, the act of running the Work is not restricted and no -requirements are made concerning any offers of support for the Work. - -2. You may distribute a complete, unmodified copy of the Work as you -received it. Distribution of only part of the Work is considered -modification of the Work, and no right to distribute such a Derived -Work may be assumed under the terms of this clause. - -3. You may distribute a Compiled Work that has been generated from a -complete, unmodified copy of the Work as distributed under Clause 2 -above, as long as that Compiled Work is distributed in such a way that -the recipients may install the Compiled Work on their system exactly -as it would have been installed if they generated a Compiled Work -directly from the Work. - -4. If you are the Current Maintainer of the Work, you may, without -restriction, modify the Work, thus creating a Derived Work. You may -also distribute the Derived Work without restriction, including -Compiled Works generated from the Derived Work. Derived Works -distributed in this manner by the Current Maintainer are considered to -be updated versions of the Work. - -5. If you are not the Current Maintainer of the Work, you may modify -your copy of the Work, thus creating a Derived Work based on the Work, -and compile this Derived Work, thus creating a Compiled Work based on -the Derived Work. - -6. If you are not the Current Maintainer of the Work, you may -distribute a Derived Work provided the following conditions are met -for every component of the Work unless that component clearly states -in the copyright notice that it is exempt from that condition. Only -the Current Maintainer is allowed to add such statements of exemption -to a component of the Work. - - a. If a component of this Derived Work can be a direct replacement - for a component of the Work when that component is used with the - Base Interpreter, then, wherever this component of the Work - identifies itself to the user when used interactively with that - Base Interpreter, the replacement component of this Derived Work - clearly and unambiguously identifies itself as a modified version - of this component to the user when used interactively with that - Base Interpreter. - - b. Every component of the Derived Work contains prominent notices - detailing the nature of the changes to that component, or a - prominent reference to another file that is distributed as part - of the Derived Work and that contains a complete and accurate log - of the changes. - - c. No information in the Derived Work implies that any persons, - including (but not limited to) the authors of the original version - of the Work, provide any support, including (but not limited to) - the reporting and handling of errors, to recipients of the - Derived Work unless those persons have stated explicitly that - they do provide such support for the Derived Work. - - d. You distribute at least one of the following with the Derived Work: - - 1. A complete, unmodified copy of the Work; - if your distribution of a modified component is made by - offering access to copy the modified component from a - designated place, then offering equivalent access to copy - the Work from the same or some similar place meets this - condition, even though third parties are not compelled to - copy the Work along with the modified component; - - 2. Information that is sufficient to obtain a complete, - unmodified copy of the Work. - -7. If you are not the Current Maintainer of the Work, you may -distribute a Compiled Work generated from a Derived Work, as long as -the Derived Work is distributed to all recipients of the Compiled -Work, and as long as the conditions of Clause 6, above, are met with -regard to the Derived Work. - -8. The conditions above are not intended to prohibit, and hence do not -apply to, the modification, by any method, of any component so that it -becomes identical to an updated version of that component of the Work as -it is distributed by the Current Maintainer under Clause 4, above. - -9. Distribution of the Work or any Derived Work in an alternative -format, where the Work or that Derived Work (in whole or in part) is -then produced by applying some process to that format, does not relax or -nullify any sections of this license as they pertain to the results of -applying that process. - -10. a. A Derived Work may be distributed under a different license - provided that license itself honors the conditions listed in - Clause 6 above, in regard to the Work, though it does not have - to honor the rest of the conditions in this license. - - b. If a Derived Work is distributed under a different license, that - Derived Work must provide sufficient documentation as part of - itself to allow each recipient of that Derived Work to honor the - restrictions in Clause 6 above, concerning changes from the Work. - -11. This license places no restrictions on works that are unrelated to -the Work, nor does this license place any restrictions on aggregating -such works with the Work by any means. - -12. Nothing in this license is intended to, or may be used to, prevent -complete compliance by all parties with all applicable laws. - - -NO WARRANTY -=========== - -There is no warranty for the Work. Except when otherwise stated in -writing, the Copyright Holder provides the Work `as is', without -warranty of any kind, either expressed or implied, including, but not -limited to, the implied warranties of merchantability and fitness for a -particular purpose. The entire risk as to the quality and performance -of the Work is with you. Should the Work prove defective, you assume -the cost of all necessary servicing, repair, or correction. - -In no event unless required by applicable law or agreed to in writing -will The Copyright Holder, or any author named in the components of the -Work, or any other party who may distribute and/or modify the Work as -permitted above, be liable to you for damages, including any general, -special, incidental or consequential damages arising out of any use of -the Work or out of inability to use the Work (including, but not limited -to, loss of data, data being rendered inaccurate, or losses sustained by -anyone as a result of any failure of the Work to operate with any other -programs), even if the Copyright Holder or said author or said other -party has been advised of the possibility of such damages. - - -MAINTENANCE OF THE WORK -======================= - -The Work has the status `author-maintained' if the Copyright Holder -explicitly and prominently states near the primary copyright notice in -the Work that the Work can only be maintained by the Copyright Holder -or simply that it is `author-maintained'. - -The Work has the status `maintained' if there is a Current Maintainer -who has indicated in the Work that they are willing to receive error -reports for the Work (for example, by supplying a valid e-mail -address). It is not required for the Current Maintainer to acknowledge -or act upon these error reports. - -The Work changes from status `maintained' to `unmaintained' if there -is no Current Maintainer, or the person stated to be Current -Maintainer of the work cannot be reached through the indicated means -of communication for a period of six months, and there are no other -significant signs of active maintenance. - -You can become the Current Maintainer of the Work by agreement with -any existing Current Maintainer to take over this role. - -If the Work is unmaintained, you can become the Current Maintainer of -the Work through the following steps: - - 1. Make a reasonable attempt to trace the Current Maintainer (and - the Copyright Holder, if the two differ) through the means of - an Internet or similar search. - - 2. If this search is successful, then enquire whether the Work - is still maintained. - - a. If it is being maintained, then ask the Current Maintainer - to update their communication data within one month. - - b. If the search is unsuccessful or no action to resume active - maintenance is taken by the Current Maintainer, then announce - within the pertinent community your intention to take over - maintenance. (If the Work is a LaTeX work, this could be - done, for example, by posting to comp.text.tex.) - - 3a. If the Current Maintainer is reachable and agrees to pass - maintenance of the Work to you, then this takes effect - immediately upon announcement. - - b. If the Current Maintainer is not reachable and the Copyright - Holder agrees that maintenance of the Work be passed to you, - then this takes effect immediately upon announcement. - - 4. If you make an `intention announcement' as described in 2b. above - and after three months your intention is challenged neither by - the Current Maintainer nor by the Copyright Holder nor by other - people, then you may arrange for the Work to be changed so as - to name you as the (new) Current Maintainer. - - 5. If the previously unreachable Current Maintainer becomes - reachable once more within three months of a change completed - under the terms of 3b) or 4), then that Current Maintainer must - become or remain the Current Maintainer upon request provided - they then update their communication data within one month. - -A change in the Current Maintainer does not, of itself, alter the fact -that the Work is distributed under the LPPL license. - -If you become the Current Maintainer of the Work, you should -immediately provide, within the Work, a prominent and unambiguous -statement of your status as Current Maintainer. You should also -announce your new status to the same pertinent community as -in 2b) above. - - -WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE -====================================================== - -This section contains important instructions, examples, and -recommendations for authors who are considering distributing their -works under this license. These authors are addressed as `you' in -this section. - -Choosing This License or Another License ----------------------------------------- - -If for any part of your work you want or need to use *distribution* -conditions that differ significantly from those in this license, then -do not refer to this license anywhere in your work but, instead, -distribute your work under a different license. You may use the text -of this license as a model for your own license, but your license -should not refer to the LPPL or otherwise give the impression that -your work is distributed under the LPPL. - -The document `modguide.tex' in the base LaTeX distribution explains -the motivation behind the conditions of this license. It explains, -for example, why distributing LaTeX under the GNU General Public -License (GPL) was considered inappropriate. Even if your work is -unrelated to LaTeX, the discussion in `modguide.tex' may still be -relevant, and authors intending to distribute their works under any -license are encouraged to read it. - -A Recommendation on Modification Without Distribution ------------------------------------------------------ - -It is wise never to modify a component of the Work, even for your own -personal use, without also meeting the above conditions for -distributing the modified component. While you might intend that such -modifications will never be distributed, often this will happen by -accident -- you may forget that you have modified that component; or -it may not occur to you when allowing others to access the modified -version that you are thus distributing it and violating the conditions -of this license in ways that could have legal implications and, worse, -cause problems for the community. It is therefore usually in your -best interest to keep your copy of the Work identical with the public -one. Many works provide ways to control the behavior of that work -without altering any of its licensed components. - -How to Use This License ------------------------ - -To use this license, place in each of the components of your work both -an explicit copyright notice including your name and the year the work -was authored and/or last substantially modified. Include also a -statement that the distribution and/or modification of that -component is constrained by the conditions in this license. - -Here is an example of such a notice and statement: - - %% pig.dtx - %% Copyright 2005 M. Y. Name - % - % This work may be distributed and/or modified under the - % conditions of the LaTeX Project Public License, either version 1.3 - % of this license or (at your option) any later version. - % The latest version of this license is in - % http://www.latex-project.org/lppl.txt - % and version 1.3 or later is part of all distributions of LaTeX - % version 2005/12/01 or later. - % - % This work has the LPPL maintenance status `maintained'. - % - % The Current Maintainer of this work is M. Y. Name. - % - % This work consists of the files pig.dtx and pig.ins - % and the derived file pig.sty. - -Given such a notice and statement in a file, the conditions -given in this license document would apply, with the `Work' referring -to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being -generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' -referring to any `LaTeX-Format', and both `Copyright Holder' and -`Current Maintainer' referring to the person `M. Y. Name'. - -If you do not want the Maintenance section of LPPL to apply to your -Work, change `maintained' above into `author-maintained'. -However, we recommend that you use `maintained', as the Maintenance -section was added in order to ensure that your Work remains useful to -the community even when you can no longer maintain and support it -yourself. - -Derived Works That Are Not Replacements ---------------------------------------- - -Several clauses of the LPPL specify means to provide reliability and -stability for the user community. They therefore concern themselves -with the case that a Derived Work is intended to be used as a -(compatible or incompatible) replacement of the original Work. If -this is not the case (e.g., if a few lines of code are reused for a -completely different task), then clauses 6b and 6d shall not apply. - - -Important Recommendations -------------------------- - - Defining What Constitutes the Work - - The LPPL requires that distributions of the Work contain all the - files of the Work. It is therefore important that you provide a - way for the licensee to determine which files constitute the Work. - This could, for example, be achieved by explicitly listing all the - files of the Work near the copyright notice of each file or by - using a line such as: - - % This work consists of all files listed in manifest.txt. - - in that place. In the absence of an unequivocal list it might be - impossible for the licensee to determine what is considered by you - to comprise the Work and, in such a case, the licensee would be - entitled to make reasonable conjectures as to which files comprise - the Work. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2019] [SJTUG] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile index 5024f1eb..d199c8ea 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,46 @@ # Makefile for SJTUThesis -PACKAGE = sjtuthesis - -SOURCE_DIR = source -LOGO_DIR = logos -RELEASE_DIR = release -SAMPLE_DIR = sample +# Basename of thesis THESIS = thesis -SOURCE = $(SOURCE_DIR)/$(PACKAGE).dtx -SCRIPTS = $(SOURCE_DIR)/latexmkrc.pl $(SOURCE_DIR)/sample.bat $(SOURCE_DIR)/sample.mk -LOGOS = $(LOGO_DIR)/sjtu-badge.pdf $(LOGO_DIR)/sjtu-logo.pdf $(LOGO_DIR)/sjtu-name.pdf +# Option for latexmk +LATEXMK_OPT = -xelatex -quiet -file-line-error -halt-on-error -interaction=nonstopmode +LATEXMK_OPT_PVC = $(LATEXMK_OPT_BASE) -pvc + +# make deletion work on Windows +ifdef SystemRoot + RM = del /Q + OPEN = start +else + RM = rm -f + OPEN = open +endif + +.PHONY : all pvc view wordcount clean cleanall FORCE_MAKE + +all : $(THESIS).pdf -VERSION = $(shell git describe --tags) -TEXMF = $(shell kpsewhich --var-value TEXMFHOME) +$(THESIS).pdf : $(THESIS).tex FORCE_MAKE + @latexmk $(LATEXMK_OPT) $< -TDS_ARCHIVE = $(RELEASE_DIR)/$(PACKAGE).tds.zip -PACK = scripts/pack.sh +pvc : $(THESIS).tex + @latexmk $(LATEXMK_OPT_PVC) $(THESIS) -.PHONY : all install +view : $(THESIS).pdf + $(OPEN) $< -all : $(TDS_ARCHIVE) +wordcount : $(THESIS).tex + @if grep -v ^% $< | grep -q '\\documentclass\[[^\[]*english'; then \ + texcount $< -inc -char-only | awk '/total/ {getline; print "英文字符数\t\t\t:",$$4}'; \ + else \ + texcount $< -inc -ch-only | awk '/total/ {getline; print "纯中文字数\t\t\t:",$$4}'; \ + fi + @texcount $< -inc -chinese | awk '/total/ {getline; print "总字数(英文单词 + 中文字)\t:",$$4}' -$(TDS_ARCHIVE) : $(PACK) $(SOURCE) $(SCRIPTS) $(LOGOS) - @$(PACK) $(SOURCE_DIR) $(LOGO_DIR) $(SAMPLE_DIR) $(RELEASE_DIR) $(VERSION) +clean : + -@latexmk -c -silent $(THESIS).tex 2> /dev/null + -@rm -f $(TEX_DIR)/*.aux 2> /dev/null || true -install : $(TDS_ARCHIVE) - unzip -o -q $(TDS_ARCHIVE) -d $(TEXMF)/ +cleanall : + -@latexmk -C -silent $(THESIS).tex 2> /dev/null + -@rm -f $(TEX_DIR)/*.aux 2> /dev/null || true diff --git a/README.md b/README.md index 1cc74998..abf8e0f7 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,97 @@ -# SJTUThesis +# SJTUThesis 示例模板 [![Build Status](https://travis-ci.org/sjtug/SJTUThesis.svg?branch=master)](https://travis-ci.org/sjtug/SJTUThesis) -[![GitHub Release](https://img.shields.io/github/release/sjtug/SJTUThesis.svg)](https://github.com/sjtug/SJTUThesis/releases) -[![GitHub Release Date](https://img.shields.io/github/release-date/sjtug/SJTUThesis.svg)](https://github.com/sjtug/SJTUThesis/releases) +[![SJTUTeX](https://img.shields.io/badge/SJTUTheis-v1.0.0rc4-green.svg)](https://github.com/sjtug/SJTUTeX) [![Join the chat at https://gitter.im/sjtug/SJTUThesis](https://badges.gitter.im/sjtug/SJTUThesis.svg)](https://gitter.im/sjtug/SJTUThesis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## 欢迎使用上海交通大学论文模板 -这是为撰写上海交通大学学士、硕士、博士学位论文以及课程论文而准备的(非官方)LaTeX 模板。 +本示例模板是应用上海交通大学学位论文(非官方)LaTeX 文档类 SJTUThesis 的一个完整实现。演示了排版中常用的例子,包括公式、表格、算法、参考文献等。 +用户可以参考或者直接基于此示例文档撰写论文。 -本模板目前仅支持 XeTeX 引擎,字符编码仅支持 UTF-8。 +请注意 SJTUThesis 目前仅支持 XeTeX 引擎,字符编码仅支持 UTF-8。 -## 获取 SJTUThesis +## 获取模板 ### 下载模版 -普通用户推荐在 [Releases](https://github.com/sjtug/SJTUThesis/releases) 页面下载打包好的压缩包直接使用。 - -| 文件名 | 描述 | -| --- | --- | -| sjtuthesis-vXXX.zip | 本地使用的模版压缩包,包含示例文档 | -| sjtuthesis.tds.zip | 按 TDS(TeX Directory Structure)组织的压缩包 | -| sjtuthesis.pdf | 模版的使用文档 | - -请务必仔细阅读模板的使用文档前三小节。请不要直接使用 +普通用户可以直接 `clone` 或者在 [Github](https://github.com/sjtug/SJTUThesis) 页面下载仓库代码。 ```bash -xelatex thesis.tex +git clone https://github.com/sjtug/SJTUThesis.git ``` -进行编译。推荐使用已经写好的`Makefile`,Windows用户请使用配套的 -`compile.bat`。 - ### Overleaf [Overleaf](https://www.overleaf.com?r=b3b31f49&rm=d&rs=b) 用户可以从下面的模版链接创建自己的项目。 [![Overleaf](https://img.shields.io/badge/overleaf-sjtuthesis-green.svg)](https://www.overleaf.com/latex/templates/sjtuthesis-latex-thesis-template-for-shanghai-jiao-tong-university/spmggcjfshrb?r=b3b31f49&rm=d&rs=b) -### 生成模板 +## 模板使用 + +如果你不熟悉 LaTeX 的编译流程,请**不要**直接使用编译器进行编译。针对不同的平台,模版提供了相应的编译脚本。 + +### Linux 与 macOS 用户 + +推荐使用模版提供的 `Makefile` 进行编译,具体来说我们提供了如下几条可用的命令: + +```bash +make all # 编译生成 thesis.pdf +make clean # 删除编译所产生的中间文件 +make cleanall # 删除 thesis.pdf 和所有中间文件 +make wordcount # 论文字数统计 +``` -模板的源代码代码位于 `source/sjtuthesis.dtx` 文件中,可以使用 `make` 工具生成模板: +### Windows 用户 + +对于 Windows 用户,我们也提供了编译脚本 `Compile.bat`。可以双击直接编译,也可以在命令提示符窗口中使用脚本提供的额外功能: ```bash -make # 生成模板并打包 -make install # 将 sjtuthesis 安装到本地的 TeX 系统中 +.\Compile.bat thesis # 编译生成 thesis.pdf +.\Compile.bat clean # 删除编译所产生的中间文件 +.\Compile.bat cleanall # 删除 thesis.pdf 和所有中间文件 +.\Compile.bat wordcount # 论文字数统计 ``` -生成的文件默认在 `release` 目录中。 +更多关于模板的实现细节以及使用信息,请查看使用文档 `sjtuthesis.pdf`。 + +## 反馈与贡献 -## 反馈问题 +本模版是由诸多感兴趣的同学一起维护的开源项目,我们非常欢迎问题反馈和新的贡献者! -如果在使用上有任何问题,建议先查阅项目的 [Wiki 文档](https://github.com/sjtug/SJTUThesis/wiki)。如果这些不能解决你的问题,建议以如下的顺序反馈使用过程中的问题: +### 反馈问题 + +如果在使用上有任何问题,建议先查阅项目的 [Wiki 文档](https://github.com/sjtug/SJTUThesis/wiki)。 +如果这些不能解决你的问题,建议通过以下方式进行反馈(按推荐顺序排序): * [在 GitHub 项目主页开 issue](https://github.com/sjtug/SJTUThesis/issues) (推荐) * [在水源 BBS TeX_LaTeX 版发帖](https://bbs.sjtu.edu.cn/bbsdoc?board=TeX_LaTeX) -如果你觉得项目的使用体验不好,或者想感谢我们的维护者们等等任何与使用无关的想法,都可以通过我们的[在线聊天频道](https://gitter.im/sjtug/SJTUThesis)告诉我们。 +另外也可以在我们的 [Gitter](https://gitter.im/sjtug/SJTUThesis) 在线聊天频道讨论任何有关与模版的话题。 + +### 成为贡献者 -## 如何贡献 +这个仓库是面向用户的**示例模版**,如果你有很好的排版示例,可以提交到此仓库与大家分享。如果你想要为 SJTUThesis 文档类贡献代码,可移步 [SJTUTeX](https://github.com/sjtug/SJTUTeX)。在贡献之前,你可以从[这些问题](https://github.com/sjtug/SJTUThesis/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue)开始熟悉贡献代码的流程。除了提交 Pull Request 之外,还有以下方式可以进行贡献: -SJTUThesis 是一个由诸多感兴趣的同学一起维护的开源项目,我们非常欢迎新的贡献者! 这里有很多贡献的方式: +* 帮助我们解答同学们的[问题](https://github.com/sjtug/SJTUThesis/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3Atype%2Fquestion+),这些问题你也可能遇到过并且知道如何解决; +* 与我们一起维护项目的 [Wiki 文档](https://github.com/sjtug/SJTUThesis/wiki),Wiki 任何人都可以直接编辑; +* 向周围同学安利 SJTUThesis,让更多的同学使用我们维护的模板; +* 在我们的[在线聊天频道](https://gitter.im/sjtug/SJTUThesis)上告诉我们你的使用体验,以及吐槽。如果你也想成为项目的长期维护者,也可以通过在线频道告诉我们。:-) -* 帮助我们解答同学们的[问题](https://github.com/sjtug/SJTUThesis/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3Atype%2Fquestion+),这些问题你也可能遇到过并且知道如何解决 -* 与我们一起维护项目的 [Wiki 文档](https://github.com/sjtug/SJTUThesis/wiki),Wiki 是可以直接编辑的 -* 向我们贡献代码,我们有一些对新的贡献者比较友好的问题,你可以从[这些问题](https://github.com/sjtug/SJTUThesis/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue)开始熟悉贡献代码的流程 -* 向周围同学安利 SJTUThesis,让更多的同学使用我们维护的模板 -* 在我们的[在线聊天频道上](https://gitter.im/sjtug/SJTUThesis)告诉我们你的使用体验,以及吐槽。如果你也想成为项目的长期维护者,也可以通过在线频道告诉我们 :-) ## 致谢 -* 感谢 [CTeX](http://www.ctex.org/HomePage) 提供了 LaTeX 的中文支持 -* 感谢那位最先制作出博士学位论文 LaTeX 模板的交大物理系同学 -* 感谢 William Wang 同学对模板移植做出的巨大贡献 -* 感谢 [@weijianwen](https://github.com/weijianwen) 学长一直以来的开发和维护工作 -* 感谢 [@sjtug](https://github.com/sjtug) 以及 [@dyweb](https://github.com/dyweb) 对 0.9.5 之后版本的开发和维护工作 -* 感谢所有为模板贡献过代码的[同学们](https://github.com/sjtug/SJTUThesis/graphs/contributors),以及所有测试和使用模板的各位同学 +* 感谢 [CTeX-kit](https://github.com/CTeX-org/ctex-kit) 提供了 LaTeX 的中文支持; +* 感谢那位最先制作出博士学位论文 LaTeX 模板的交大物理系同学; +* 感谢 William Wang 同学对模板移植做出的巨大贡献; +* 感谢 [@weijianwen](https://github.com/weijianwen) 学长一直以来的开发和维护工作; +* 感谢 [@sjtug](https://github.com/sjtug) 以及 [@dyweb](https://github.com/dyweb) 对 0.9.5 之后版本的开发和维护工作; +* 感谢所有为模板贡献过代码的[同学们](https://github.com/sjtug/SJTUThesis/graphs/contributors),以及所有测试和使用模板的各位同学。 ## 软件许可证 -上海交通大学校徽图片(`sjtulogo.pdf` 等)的版权归上海交通大学所有。 +上海交通大学校徽校名图片(`sjtu-logo.pdf` 等)的版权归上海交通大学所有。 + +`sjtuthesis.cls` 文档类与相关附属文件,以及 `biblatex-gb7714-2015` 样式文件使用 [LPPL](https://www.latex-project.org/lppl.txt) 授权。 -其他部分使用 [LPPL](LICENSE) 授权。 +其他部分使用 [Apache License 2.0](LICENSE) 授权。 diff --git a/README_en-US.md b/README_en-US.md index 6194498e..8dc514a5 100644 --- a/README_en-US.md +++ b/README_en-US.md @@ -1,65 +1,67 @@ -# SJTUThesis +# Sample Template of SJTUThesis [![Build Status](https://travis-ci.org/sjtug/SJTUThesis.svg?branch=master)](https://travis-ci.org/sjtug/SJTUThesis) -[![GitHub Release](https://img.shields.io/github/release/sjtug/SJTUThesis.svg)](https://github.com/sjtug/SJTUThesis/releases) -[![GitHub Release Date](https://img.shields.io/github/release-date/sjtug/SJTUThesis.svg)](https://github.com/sjtug/SJTUThesis/releases) +[![SJTUTeX](https://img.shields.io/badge/SJTUTheis-v1.0.0rc4-green.svg)](https://github.com/sjtug/SJTUTeX) [![Join the chat at https://gitter.im/sjtug/SJTUThesis](https://badges.gitter.im/sjtug/SJTUThesis.svg)](https://gitter.im/sjtug/SJTUThesis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Welcome to LaTeX thesis template for Shanghai Jiao Tong University -SJTUThesis is an *unofficial* LaTeX template for preparing bachelor, master, doctor thesis or course papers in Shanghai Jiao Tong University. +This sample template is a full implementation of SJTUThesis document class which is an *unofficial* LaTeX class for preparing degree theses or course papers in Shanghai Jiao Tong University. -At present, `sjtuthesis` only supports XeTeX engine. `sjtuthesis` only allows UTF-8 character encoding. +Please note that `sjtuthesis` only supports XeTeX engine, `sjtuthesis` only allows UTF-8 character encoding. -## Obtain SJTUThesis +## Obtain Template ### Downloads -We'd recommend to use packed files downloaded from [Releases](https://github.com/sjtug/SJTUThesis/releases) page directly for normal users. - -| Filename | Description | -| --- | --- | -| sjtuthesis-vXXX.zip | Packed file for local usage,samples included | -| sjtuthesis.tds.zip | TDS(TeX Directory Structure)package | -| sjtuthesis.pdf | Document for SJTUThesis | - -Please read `sjtuthesis.pdf` carefully before using the template. And do not -use `xelatex` to compile `thesis.tex` directly: +You can `clone` this repository directly or download from [Github](https://github.com/sjtug/SJTUThesis). ```bash -xelatex thesis.tex +git clone https://github.com/sjtug/SJTUThesis.git ``` -We highly recommend using `Makefile` or `compile.bat`(for Windows users) -to compile. - ### Overleaf -[Overleaf](https://www.overleaf.com?r=b3b31f49&rm=d&rs=b) users are able to create project from the template link below. +If you are an [Overleaf](https://www.overleaf.com?r=b3b31f49&rm=d&rs=b) user, you can create your own project through the link below. [![Overleaf](https://img.shields.io/badge/overleaf-sjtuthesis-green.svg)](https://www.overleaf.com/latex/templates/sjtuthesis-latex-thesis-template-for-shanghai-jiao-tong-university/spmggcjfshrb?r=b3b31f49&rm=d&rs=b) -### Generate manually +## Usage -The source of SJTUThesis located in `source/sjtuthesis.dtx`, you can use `make` to generate the packed files: +### Linux & macOS Users + +It is recommended to use GNU make utility with `Makefile` provided in template. ```bash -make # generate the template and pack files -make install # install sjtuthesis into your local TeX system +make all # compile and generate Thesis.pdf +make clean # remove useless files +make cleanall # remove everything produced by make all +make wordcount # count the words of the thesis ``` -The default output folder is `release`. +### Windows Users + +We also provided a batch script `Compile.bat` for Windows users. You can double-click the batch file to complie instantly, or use it in a cmd console to access extra features. + +```bash +.\Compile.bat thesis # compile and generate Thesis.pdf +.\Compile.bat clean # remove useless files +.\Compile.bat cleanall # remove everything produced by make all +.\Compile.bat wordcount # count the words of the thesis +``` ## Feedback We are hearing from: -* [issue page of Github](https://github.com/sjtug/SJTUThesis/issues) +* [Issues page of Github](https://github.com/sjtug/SJTUThesis/issues) * [SJTU BBS](https://bbs.sjtu.edu.cn/bbsdoc?board=TeX_LaTeX) ## License -The copyright of image sources including SJTU logo (`sjtulogo.pdf` etc.) +The copyright of image sources including SJTU logo (`sjtu-logo.pdf` etc.) belongs to Shanghai Jiao Tong University. -The remain part is under [LPPL](LICENSE) +`sjtuthesis.cls` document class with related files, and `biblatex-gb7714-2015` biblatex style files is under [LPPL](https://www.latex-project.org/lppl.txt). + +The remain part is under [Apache License 2.0](LICENSE). diff --git a/sample/bib/thesis.bib b/bib/thesis.bib similarity index 100% rename from sample/bib/thesis.bib rename to bib/thesis.bib diff --git a/sample/figure/cn_100t.png b/figure/cn_100t.png similarity index 100% rename from sample/figure/cn_100t.png rename to figure/cn_100t.png diff --git a/sample/figure/flow_chart.tex b/figure/flow_chart.tex similarity index 100% rename from sample/figure/flow_chart.tex rename to figure/flow_chart.tex diff --git a/sample/figure/pressure15.jpg b/figure/pressure15.jpg similarity index 100% rename from sample/figure/pressure15.jpg rename to figure/pressure15.jpg diff --git a/sample/figure/pressure25.jpg b/figure/pressure25.jpg similarity index 100% rename from sample/figure/pressure25.jpg rename to figure/pressure25.jpg diff --git a/gb7714-2015.bbx b/gb7714-2015.bbx new file mode 100644 index 00000000..7bc20e91 --- /dev/null +++ b/gb7714-2015.bbx @@ -0,0 +1,3462 @@ +%% +%% --------------------------------------------------------------- +%% biblatex-gb7714-2015 --- A biblatex implementation of the +%% GBT7714-2015 bibliography style,numerical sequence +%% Maintained by huzhenzhen +%% E-mail: hzzmail@163.com +%% Released under the LaTeX Project Public License v1.3c or later +%% --------------------------------------------------------------- +%% + +% +% 版本和时间信息 +% +\def\versionofgbtstyle{2019/08/28 v1.0s} +\def\versionofbiblatex{\abx@version} +\ProvidesFile{gb7714-2015.bbx}[\versionofgbtstyle biblatex bibliography style] +%\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 + +%===================================================================== +% 加载标准样式 +%===================================================================== +\RequireBibliographyStyle{numeric-comp} +\RequirePackage{xstring}%解决texlive2015的biblatex3.0不加载xstring包的问题 + + +%===================================================================== +% 功能函数 +%===================================================================== + % + % biblatex版本判断 + % 20180405,v1.0k,为兼容biblatexv3.11增加toggle:iftlnine,HU zhenzhen + % 20181020,v1.0n,为不再使用xstring宏包做的修改,hzz + % + % 原理方法:当版本继续更新时,增加一个新的toggle用以处理新的旧版,最新版和未判断出来的版本永远用iftlatest + \providetoggle{iftlfive}\togglefalse{iftlfive} %处理biblatex3.2之前版本,时间2016-03-01前 + \providetoggle{iftlsix}\togglefalse{iftlsix} %处理biblatex3.3开始改变姓名机制后版本,时间2016-03-01及以后 + \providetoggle{iftlseven}\togglefalse{iftlseven}%处理biblatex3.7的兼容性,时间2016-12-01后 + \providetoggle{iftleight}\togglefalse{iftleight}%处理biblatex3.8到3.9的兼容性,时间2017-11-01后到2017-12-01前 + \providetoggle{iftlnine}\togglefalse{iftlnine} %处理biblatex10的兼容性,时间2017-12-01后 + \providetoggle{iftlatest}\toggletrue{iftlatest} %假设是最新版biblatex + + \@ifpackagelater{biblatex}{2014/04/01}{ + \@ifpackagelater{biblatex}{2016/03/01}{ + \@ifpackagelater{biblatex}{2016/12/01}{ + \@ifpackagelater{biblatex}{2017/11/01}{ + \@ifpackagelater{biblatex}{2017/12/01}{ + \@ifpackagelater{biblatex}{2018/02/19}{} + {\toggletrue{iftlnine}\togglefalse{iftlatest}}} + {\toggletrue{iftleight}\togglefalse{iftlatest}}} + {\toggletrue{iftlseven}\togglefalse{iftlatest}}} + {\toggletrue{iftlsix}\togglefalse{iftlatest}}} + {\toggletrue{iftlfive}\togglefalse{iftlatest}}} + {\PackageError{biblatex}{Outdated 'biblatex' package} + {Please update biblatex, This is a fatal error.}} + + \newcommand\defversion[2]{\csdef{codeversion#1#2}}%定义不同版本的命令 + \newcommand\switchversion[2]{\csuse{codeversion#1#2}}%使用不同版本的命令 + + % + % 判断CJK字符的函数,用于判断作者等信息是否由中文字符构成 + % v1.0k,20180509,hzz + % + % 原理方法:用biber中的perl方法代替。因为利用tex函数对字符判断时,当字符在宏 + % 中时,基于`的方法无法解决GBK编码的问题,基于CJKsymbol的方法无法解决utf-8 + % 编码用xelatex编译的问题。 + % + % 原理是:利用perl正则将中文标识记录到域中, + % 然后利用\iffieldundef和\iffieldequalstr进行判断 + \providetoggle{ifCJKforgbt} + \def\testCJKfirst#1{% + \iffieldundef{#1}{\togglefalse{ifCJKforgbt}}{% + \iffieldequalstr{#1}{chinese}{\toggletrue{ifCJKforgbt}}{\togglefalse{ifCJKforgbt}}}} + + % + % 2个卷的解析函数,用于连续出版物 + % + % 原理方法: 范围起止间隔符号还是用-,而不是与date相同的/,因为有合期期刊的问题,需要用到/符号 + \newcommand{\multivolparser}[1]{% + \IfSubStr{#1}{-}% + {\StrBefore{#1}{-}[\multivolfirst]\StrBehind{#1}{-}[\multivolsecond]}% + {\def\multivolfirst{#1}\def\multivolsecond{}}% + } + + + % + % 2个期的解析函数,用于连续出版物 + % + \newcommand{\multinumberparser}[1]{% + \IfSubStr{#1}{-}% + {\StrBefore{#1}{-}[\multinumberfirst]\StrBehind{#1}{-}[\multinumbersecond]}% + {\def\multinumberfirst{#1}\def\multinumbersecond{}}% + } + + % 对没有分隔符环境命令的低版本biblatex做增补,避免报错 + % + \iftoggle{iftlfive}{ + + \def\blx@inf@delimdeclare#1#2{% + \blx@info{Delimiter '#1' in context '#2' already defined, overwriting}} + + \def\blx@warn@delimuse#1#2{% + \blx@warning{Delimiter '#1' in context '#2' undefined}} + % Delimiter interface + + % []{}{} + \newrobustcmd*{\DeclareDelimFormat}{% + \@ifstar + {\blx@declaredelimclear} + {\blx@declaredelim}} + + \newrobustcmd*{\blx@declaredelimclear}[3][]{% + \ifcsvoid{blx@declaredelimcontexts@#2} + {} + {\def\do##1{\csundef{blx@printdelim@##1@#2}}% + \dolistcsloop{blx@declaredelimcontexts@#2}}% + \cslet{blx@declaredelimcontexts@#2}\@empty + \ifblank{#1} + {\blx@declaredelim{#2}{#3}} + {\blx@declaredelim[#1]{#2}{#3}}} + + \newrobustcmd*{\blx@declaredelim}[3][]{% + \ifblank{#1} + {\blx@declaredelim@i{}{}{#2}{#3}} + {\def\do##1{% + \listcsadd{blx@declaredelimcontexts@#2}{##1}% + \blx@declaredelim@i{blx@printdelim@##1@}{##1}{#2}{#3}}% + \docsvlist{#1}}}% + + \def\blx@declaredelim@i#1#2#3#4{% + \def\do@i##1{% + \ifcsdef{#1##1} + {\blx@inf@delimdeclare{##1}{#2}} + {}% + \csdef{#1##1}{#4}}% + \forcsvlist{\do@i}{#3}} + + % *[]{}{} + \newrobustcmd*{\DeclareDelimAlias}{% + \@ifstar + {\blx@declaredelimalias} + {\blx@declaredelimaliasauto}} + + \newrobustcmd*{\blx@declaredelimalias}[3][]{% + \ifblank{#1} + {\blx@declaredelimalias@i{}{#2}{#3}} + {\def\do##1{% + \blx@declaredelimalias@i{blx@printdelim@##1@}{#2}{#3}}% + \docsvlist{#1}}} + + \newrobustcmd*{\blx@declaredelimaliasauto}[2]{% + \blx@declaredelimalias@i{}{#1}{#2}% + \ifcsvoid{blx@declaredelimcontexts@#2} + {} + {\def\do##1{% + \blx@declaredelimalias@i{blx@printdelim@##1@}{#1}{#2}}% + \dolistcsloop{blx@declaredelimcontexts@#2}}} + + \def\blx@declaredelimalias@i#1#2#3{% + \ifcsdef{#1#2} + {\blx@inf@delimdeclare{#2}{#1}} + {}% + \csdef{#1#2}{\csuse{#1#3}}} + + \def\blx@delimcontext{none} + \newcommand*{\printdelim}[2][]{% + \ifblank{#1} + {\ifcsdef{blx@printdelim@\blx@delimcontext @#2} + {\csuse{blx@printdelim@\blx@delimcontext @#2}} + {\ifcsdef{#2}% fall back on legacy macros + {\csuse{#2}} + {\blx@warn@delimuse{#2}{*}}}} + {\ifcsdef{blx@printdelim@#1@#2} + {\csuse{blx@printdelim@#1@#2}} + {\blx@warn@delimuse{#2}{#1}}}} + + \newcommand*{\delimcontext}[1]{% + \edef\blx@delimcontext{\blx@delimcontextalias{#1}}} + + \def\blx@delimcontextalias#1{% + \ifcsdef{blx@delimcontextalias@#1} + {\csuse{blx@delimcontextalias@#1}} + {#1}} + + \newcommand*{\DeclareDelimcontextAlias}[2]{% + \csgdef{blx@delimcontextalias@#1}{#2}} + }{} + + +%===================================================================== +% 数据模型定义 +%===================================================================== + %定义类型和载体标识,从gb内容看载体基本属于介质。 + %为与lee zeping的bst的样式统一,使用mark和medium这两域名 + %为单个条目的姓名格式控制增加nameformat和namefmtid两个域 + %为缩略信息文献表增加了shortbooktitle域 + %为多语言排序增加了lansortorder域 + \DeclareDatamodelFields[type=field,datatype=literal]{mark,medium,nameformat} + \DeclareDatamodelFields[type=field,datatype=integer]{namefmtid} + \DeclareDatamodelFields[type=field,datatype=literal]{shortbooktitle} + \DeclareDatamodelFields[type=field,datatype=literal]{lansortorder} + + + +%===================================================================== +% 设置宏包选项 +%===================================================================== + % + % 增加一个控制是否输出annotation域的选项,该域可以用于在文献条目后面输出一些注释信息 + % 20190509,v1,0s,hzz + \newtoggle{bbx:gbannote} + \DeclareBibliographyOption{gbannote}[false]{%biblatex低版本 + \settoggle{bbx:gbannote}{#1}} + \ExecuteBibliographyOptions{gbannote} + % + %用于在文献条目后面输出注释信息的宏 + %FieldFormat{annotation}用于设置注释信息的格式 + \DeclareFieldFormat{annotation}{% + \printtext{\addspace(#1)}% + } + \renewbibmacro*{annotation}{% + \iftoggle{bbx:gbannote}% + {\iffieldundef{annotation}% + {\printfile[annotation]{\bibannotationprefix\thefield{entrykey}.tex}}% + {\printfield{annotation}}}% + {}% + } + + % + % 增加一个控制是否输出type域的选项 + % 20190212,v1,0q,hzz + \newtoggle{bbx:gbfieldtype} + \DeclareBibliographyOption{gbfieldtype}[false]{%biblatex低版本 + \settoggle{bbx:gbfieldtype}{#1}} + \ExecuteBibliographyOptions{gbfieldtype} + + % + % 增加一个控制是否根据页码重设脚注数字标号的选项 + % 20190422,v1,0r,hzz + \newtoggle{bbx:gbfnperpage} + \DeclareBibliographyOption{gbfnperpage}[false]{% + \settoggle{bbx:gbfnperpage}{#1}} + \ExecuteBibliographyOptions{gbfnperpage} + + + % + % 增加一个选项,用于控制是否实现GB/T 7714-2015标准的脚注文献表 + % 20190203,v1.0p,hzz + % 原理方法:默认做patch,文献引用带圈上标数字表示,脚注中的文献用带圈非上标数字做标签 + % 当前面的脚注中已经存在当前文献,那么当前文献内容不再输出而用同(4)这样的方式 + % 需要注意的是由于小页环境和表格中的脚注本身的问题,可能会有一些问题 + \DeclareBibliographyOption{gbfootbib}[false]{% + \ifstrequal{#1}{false}{}{\execgbfootbib}} + \ExecuteBibliographyOptions{gbfootbib} + + %% + \newlength{\footbibmargin} + \newlength{\footbiblabelsep} + \setlength{\footbibmargin}{1em}%脚注的段落左侧缩进距离 + \setlength{\footbiblabelsep}{0.5em}%脚注中标记号与脚注段落的间距 + \def\execgbfootbib% + {% + %开启引用跟踪计数器,为使用\ifciteseen等测试命令 + \ExecuteBibliographyOptions{citetracker=true} + % + %利用footmisc宏包来实现脚注文献的悬挂对齐 + \AtEndPreamble{ + \@ifclassloaded{beamer}{}{ + %beamer类因为其特殊性,为避免冲突不调footmisc。 + %同时footmisc与hyperref宏包也不兼容,所以使用footmisc时会破坏脚注的超链接 + %如果要实现超链接可以将下句注释掉,这里留着主要是实现悬挂对齐。 + %\PassOptionsToPackage{perpage,hang}{footmisc}% + %\RequirePackage{footmisc}% + + %重新实现脚注的根据单页重设脚注号码 + %重新实现脚注的悬挂对齐问题,不再使用footmisc,直接从latex核心代码和hyperref代码进行修改 + %v1.0q 20190317 hzz + %v1.0r 20190422 hzz 根据gbfnperpage选项设置 + \iftoggle{bbx:gbfnperpage}% + {\@addtoreset{footnote}{page}}{}%重设计数器 + +\@ifpackageloaded{hyperref}{%加载hyperref则对\H@@footnotetext做重定义 + \long\def\H@@footnotetext##1{\insert\footins{% + \reset@font\footnotesize + \interlinepenalty\interfootnotelinepenalty + \splittopskip\footnotesep + \splitmaxdepth \dp\strutbox \floatingpenalty \@MM + \hsize\columnwidth \@parboxrestore + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark + }% + \color@begingroup + \leftskip \footbibmargin%增加的左侧缩进 + \@makefntext{% + \rule\z@\footnotesep\ignorespaces##1\@finalstrut\strutbox% + }% + \color@endgroup}}% + + \long\def\H@@mpfootnotetext##1{% + \global\setbox\@mpfootins\vbox{% + \unvbox\@mpfootins + \reset@font\footnotesize + \hsize\columnwidth + \@parboxrestore + \protected@edef\@currentlabel + {\csname p@mpfootnote\endcsname\@thefnmark}% + \leftskip \footbibmargin%增加的左侧缩进 + \color@begingroup + \@makefntext{% + \rule\z@\footnotesep\ignorespaces##1\@finalstrut\strutbox}% + \color@endgroup}} + }{%否则对latex核心代码中的\@footnotetext做重定义 + \long\def\@footnotetext##1{\insert\footins{% + \reset@font\footnotesize + \interlinepenalty\interfootnotelinepenalty + \splittopskip\footnotesep + \splitmaxdepth \dp\strutbox \floatingpenalty \@MM + \hsize\columnwidth \@parboxrestore + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark + }% + \color@begingroup + \leftskip \footbibmargin%增加的左侧缩进 + \@makefntext{% + \rule\z@\footnotesep\ignorespaces##1\@finalstrut\strutbox% + }% + \color@endgroup}}% + + \long\def\@mpfootnotetext##1{% + \global\setbox\@mpfootins\vbox{% + \unvbox\@mpfootins + \reset@font\footnotesize + \hsize\columnwidth + \@parboxrestore + \protected@edef\@currentlabel + {\csname p@mpfootnote\endcsname\@thefnmark}% + \leftskip \footbibmargin%增加的左侧缩进 + \color@begingroup + \@makefntext{% + \rule\z@\footnotesep\ignorespaces##1\@finalstrut\strutbox}% + \color@endgroup}} + } + + \long\def\@makefntext##1{%增加了脚注标记与正文的间隔 + \parindent 1em\noindent \hb@xt@ 0em{\hss \@makefnmark\makebox[\footbiblabelsep]{}}##1} + + } + + % + %使脚注标记加圈并设置数字的字体为tiny,不使用修改thefootnote的方式 + \def\@makefnmark{\hbox{\@textsuperscript{\textcircled{\tiny\@thefnmark}}}} + %做patch使得脚注内容中的脚注数字标签不上标 + \pretocmd{\@makefntext}{% + \def\@makefnmark{% + \hbox{\textcircled{\tiny\@thefnmark}}% + }% + }{}{} + } + + % + %判断当前文献是否已经引用过且是做的footfullcite(即已经作为脚注输出文献内容) + %记录首次输出时的脚注号码,用于后面再次引用该文献时的输出,比如同(4)。 + %v1.0q 20190309 区分使脚注标注适应minipage中的情况 + \newbibmacro*{citesavefn}{% + \ifciteseen%当被引用过为true + {\ifcsdef{sec\arabic{refsection}\arabic{page}et\thefield{entrykey}}%当已经定义过脚注序号信息 + {\csgdef{labelsec\arabic{refsection}\arabic{page}et\thefield{entrykey}}{% + \str@sameentry\gdef\@thefnmark{\csuse{sec\arabic{refsection}\arabic{page}et\thefield{entrykey}}}% + \@makefnmark% + }}% + {\csxdef{sec\arabic{refsection}\arabic{page}et\thefield{entrykey}}{% + \ifcsstring{@mpfn}{mpfootnote}{\@alph\c@mpfootnote}{\thefootnote}% + }}% + }% + {\csxdef{sec\arabic{refsection}\arabic{page}et\thefield{entrykey}}{% + \ifcsstring{@mpfn}{mpfootnote}{\@alph\c@mpfootnote}{\thefootnote}% + %判断在minipage中比较麻烦,这里使用\@mpfn的定义进行判断 + }}% + } + + % + %重定义\footfullcite使完成gb7714-2015的脚注文献要求 + \DeclareCiteCommand{\footfullcite}[\mkbibfootnote]% + {\defcounter{maxnames}{\blx@maxbibnames}%局部定义maxnames和minnames计数器 + \defcounter{minnames}{\blx@minbibnames}%使footfullcite内的作者输出与正文文献表中的一致。 + \usebibmacro{prenote}% + \renewbibmacro*{postnote}{% + \iffieldundef{postnote}% + {}{\setunit{\addcolon\addspace}\printfield{postnote}}}%与ay样式不同,由于已修改postnote域格式,直接用printfield + }% + {\usebibmacro{citesavefn}% + \ifcsdef{labelsec\arabic{refsection}\arabic{page}et\thefield{entrykey}}% + {\csuse{labelsec\arabic{refsection}\arabic{page}et\thefield{entrykey}}}%\nopunct + {\usedriver{\DeclareNameAlias{sortname}{default}}{\thefield{entrytype}}}% + }% + {\multicitedelim}% + {\usebibmacro{postnote}} + + } + + % + % 增加一个选项,用于控制gb7714的使用范围,即英文文献和中文文献使用不同的样式 + % 20180814,v1.0m,hzz + % 原理方法: + % 只为兼容性考虑不做任何处理 + \DeclareBibliographyOption{gbstyle}[true]{%biblatex低版本 + } + + % + % 增加一个控制是否输出文献类型和载体标识的选项 + % + % 原理方法: + % 对于biblatex3.4以上版本DeclareBibliographyOption命令中的[datatype]如果是boolean,那么是可以省略的 + % 所以用老版本的不用[datatype]的命令可以兼容所有biblatex版本 + \newtoggle{bbx:gbtype} + %\DeclareBibliographyOption[boolean]{gbtype}[true]{%biblatex高版本 + \DeclareBibliographyOption{gbtype}[true]{%biblatex低版本 + \settoggle{bbx:gbtype}{#1}} + \ExecuteBibliographyOptions{gbtype} + + % + % 增加一个源文件编码选择选项,当true时可以使用GBK编码。 + % v1.0k, 2018.05.08, by hzz + % + % 原理方法:将需要输出的中文字符串用命令形式表示存储,采用utf8编码时采用bbx文档 + % 内的定义即是utf8编码的中文字符串,但tex源文件是gbk编码时,利用gb7714-2015-gbk.def + % 文档内的gbk编码的字符串覆盖。这种覆盖只能在宏包末尾加载时成功实现,所以使用 + % AtEndOfPackage。该解决思路源自biblatex-caspervector宏包。 + % 另外注意: + % gbk编码的tex文档,利用pdflatex/latex能正确编译,利用xelatex能编译,但中文显示乱码 + % 在源文档前面增加 XeTeX 原语:\XeTeXinputencoding "GBK" 后,显示正常 + % utf-8编码的tex文档,利用xelatex能正确编译,而pdflatex/latex不能编译。 + \newtoggle{bbx:codegbk} + \DeclareBibliographyOption{gbcodegbk}[false]{% + \settoggle{bbx:codegbk}{#1}} + \ExecuteBibliographyOptions{gbcodegbk} + + \def\str@bibliography{参考文献} + \def\str@references{参考文献} + \def\str@bytranslator{译} + \def\str@andotherscn{等} + \def\str@backrefpage{引用页} + \def\str@backrefpages{引用页} + \def\str@noaddress{出版地不详} + \def\str@nopublisher{出版者不详} + \def\str@edition{版} + \def\str@volumecn{卷} + \def\str@numbercn{册} + \def\str@serialcn{第} + \def\str@sameentry{同} + \def\str@incn{见} + \def\str@mathesiscn{硕士学位论文} + \def\str@phdthesiscn{博士学位论文} + \def\str@editorcn{主编} + + \AtEndOfPackage{% + \iftoggle{bbx:codegbk}{% + \ExecuteBibliographyOptions{texencoding = GBK} + \input{gb7714-2015-gbk.def} + }{}} + + % + % 增加一个严格按GB/T 7714-2015给出著录格式控制域的输出的选项 + % v1.0k, 2018.05.08, by hzz + % + % 原理方法: + % 默认设置该选项为真,进而不输出GB/T 7714-2015中没有的域的信息 + % 这样可以避免因为bib文件带有多余的域的信息的输出,比如因为bibtex样式 + % 可能需要用于中英文判断的language域的信息。 + \newtoggle{bbx:gbstrict} + \DeclareBibliographyOption{gbstrict}[true]{% + \settoggle{bbx:gbstrict}{#1}} + \ExecuteBibliographyOptions{gbstrict} + + % + % 增加一个控制标题域超链接设置的选项 + % v1.0k, 2018.05.24, by hzz + % + % 原理方法: + % 利用标题域格式来实现,默认设置该选项为false,不做超链接。 + % 设置为true,则标题设置超链接 + \newtoggle{bbx:titlelink} + \DeclareBibliographyOption{gbtitlelink}[false]{% + \settoggle{bbx:titlelink}{#1}} + \ExecuteBibliographyOptions{gbtitlelink} + + % + % 增加一个控制参考文献标题是否能够被ctex宏包设置的选项 + % v1.0l, 2018.07.02, by hzz + % + % 原理方法: + % 重定义biblatex的宏,去除使用本地化字符串的方式,是的可以利用ctexset进行设置 + \newtoggle{bbx:ctexset} + \DeclareBibliographyOption{gbctexset}[true]{% + \settoggle{bbx:ctexset}{#1}} + \ExecuteBibliographyOptions{gbctexset} + + \AtEndOfPackage{% + \iftoggle{bbx:ctexset}{% + \def\blx@defbibstrings#1#2{% + \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}% + \abx@dostrings + \csuse{abx@strings@#1}% + \setkeys{blx@lbx}{#2}% + \let\do\blx@defbibstrings@i + \csxdef{abx@strings@#1}{\abx@dostrings}% + } + }{}} + + + + % + % 增加一个恢复域格式为标准样式的控制选项 + % v1.0k, 2018.05.15, by hzz + % + % 原理方法: + % 默认设置该选项为false,采用国标要求的域格式输出相关域 + % 当设置该选项为true时,则重新利用标准样式的域格式输出相关的域 + \newtoggle{bbx:gbfieldstd} + \DeclareBibliographyOption{gbfieldstd}[false]{% + \settoggle{bbx:gbfieldstd}{#1}% + \ifstrequal{#1}{false}{}{\execgbfdfmtstd}% + } + \ExecuteBibliographyOptions{gbfieldstd} + + % + % 增加一个出版项自动处理控制选项,当true时使用出版者不详等信息补充缺失的出版信息。 + % + \newtoggle{bbx:gbpub} + \DeclareBibliographyOption{gbpub}[true]{% + %\settoggle{bbx:gbpub}{#1} %或采用下面这一句 + \ifstrequal{#1}{false}{\togglefalse{bbx:gbpub}}{\toggletrue{bbx:gbpub}}} + \ExecuteBibliographyOptions{gbpub} + + % + % 增加控制析出文献来源前的标点符号//输出的选项 + % v1.0k, 2018.04.20,added in by hzz + \newtoggle{bbx:gbpunctin} + \DeclareBibliographyOption{gbpunctin}[true]{% + \settoggle{bbx:gbpunctin}{#1}} + \ExecuteBibliographyOptions{gbpunctin} + + + % + % 增加一个处理佚名或noauthor的控制选项 + % + % 原理方法:在顺序编码制中不需要使用,为与作者年制的兼容性考虑,这里也增加避免报错 + \DeclareBibliographyOption{gbnoauthor}[true]{}% + + + % + % 选项设置 + % + \ExecuteBibliographyOptions{ + sorting=none, + useprefix=true, %名字的信息包括前缀 + date = year, %日期仅写到年 + maxbibnames = 3,%设置名字最大数量 + minbibnames = 3, %设置缩减后的名字最小数量 + maxitems = 1,%设置列表最大数量 + minitems = 1, %设置缩减后的列表最小数量 + isbn=false, + } + + % + %为日期相关选项增加选项值gb7714-2015 + % + \csdef{mkdaterangegb7714-2015}#1{% + \begingroup + \blx@metadateinfo{#1}% + \iffieldundef{#1year} + {} + {\printtext[#1date]{% + \blx@gbdate{#1}{}}}% + \endgroup} + + \newrobustcmd*{\blx@gbdate}[3][]{% + \dateeraprintpre{#2#3year}% + \blx@imc@forcezerosy{\thefield{#2#3year}}\ifblank{#1}{}{\printfield{#1}}% + \iffieldundef{#2#3month}{}{\hyphen\blx@imc@forcezerosmdt{\thefield{#2#3month}}}% + \iffieldundef{#2#3day}{}{\hyphen\blx@imc@forcezerosmdt{\thefield{#2#3day}}}} + + + %为姓名格式选择增加的计数器 + \newcounter{gbnamefmtcase} + \def\thegbnamefmtcase{\the\c@gbnamefmtcase} + %为数字标签格式选择增加的计数器/命令 + \newcommand{\mkgbnumlabel}[1]{\mkbibbrackets{#1}} + \def\gbbiblabelopt@bracket{\renewcommand{\mkgbnumlabel}[1]{\mkbibbrackets{##1}}} + \def\gbbiblabelopt@parens{\renewcommand{\mkgbnumlabel}[1]{\mkbibparens{##1}}} + \def\gbbiblabelopt@dot{\renewcommand{\mkgbnumlabel}[1]{##1\adddot}} + \def\gbbiblabelopt@plain{\renewcommand{\mkgbnumlabel}[1]{##1}} + \def\gbbiblabelopt@box{\renewcommand{\mkgbnumlabel}[1]{\framebox{##1}}} + \def\gbbiblabelopt@circle{\renewcommand{\mkgbnumlabel}[1]{\textcircled{##1}}} + %为文献表中数字标签对齐方式选择增加的计数器/命令 + \newcounter{gbalignlabel} + \def\thegbalignlabel{\the\c@gbalignlabel} + %为引用标签标注/文献表中本地化字符串中英文选择增加的计数器/命令 + \newcounter{gbcitelocalcase} + \newcounter{gbbiblocalcase} + \def\thegbcitelocalcase{\the\c@gbcitelocalcase} + \def\thegbbiblocalcase{\the\c@gbbiblocalcase} + +\@ifpackagelater{biblatex}{2016/03/27} + { % 针对biblatex>=3.3版本的选项设置 + % 增加不同语言排序的切换选项 + % numeric样式,不使用该选项,这里给出仅为兼容性考虑 + % v1.0q,20190307,hzz + % + \DeclareBibliographyOption[string]{gblanorder}[chineseahead]{} + + % + % 增加本地化字符串的中英文切换选项 + % gbcitelocal指标注中的本地化字符串 + % gbbiblocal 指文献表中的本地化字符串 + % gblocal 指设置文献表和标注中的本地化字符串 + % v1.0o,20190103,hzz + % + \DeclareBibliographyOption[string]{gbcitelocal}[gb7714-2015]{% + \ifstrequal{#1}{gb7714-2015}{\setcounter{gbcitelocalcase}{0}}{}% + \ifstrequal{#1}{chinese}{\setcounter{gbcitelocalcase}{1}}{}% + \ifstrequal{#1}{english}{\setcounter{gbcitelocalcase}{2}}{}% + } + \ExecuteBibliographyOptions{gbcitelocal} + + \DeclareBibliographyOption[string]{gbbiblocal}[gb7714-2015]{% + \ifstrequal{#1}{gb7714-2015}{\setcounter{gbbiblocalcase}{0}}{}% + \ifstrequal{#1}{chinese}{\setcounter{gbbiblocalcase}{1}}{}% + \ifstrequal{#1}{english}{\setcounter{gbbiblocalcase}{2}}{}% + } + \ExecuteBibliographyOptions{gbbiblocal} + + \DeclareBibliographyOption[string]{gblocal}[gb7714-2015]{% + \ExecuteBibliographyOptions{gbbiblocal=#1}% + \ExecuteBibliographyOptions{gbcitelocal=#1}% + } + %\ExecuteBibliographyOptions{gblocal} %默认值已经通过两个相关选项设置 + + % + % 增加序号标签格式处理选项 + % v1.0l,20180623,hzz + % + \DeclareBibliographyOption[string]{gbbiblabel}[bracket]{% + \csuse{gbbiblabelopt@#1} + } + \ExecuteBibliographyOptions{gbbiblabel} + + % + % 增加姓名大小写格式处理选项 + % + \DeclareBibliographyOption[string]{gbnamefmt}[uppercase]{% + \ifstrequal{#1}{uppercase}{\setcounter{gbnamefmtcase}{0}}{}% + \ifstrequal{#1}{lowercase}{\setcounter{gbnamefmtcase}{1}}{}% + \ifstrequal{#1}{givenahead}{\setcounter{gbnamefmtcase}{2}}{}%given-family + \ifstrequal{#1}{familyahead}{\setcounter{gbnamefmtcase}{3}}{} + \ifstrequal{#1}{pinyin}{\setcounter{gbnamefmtcase}{4}}{}%family-given + \ifstrequal{#1}{reverseorder}{\setcounter{gbnamefmtcase}{5}}{}%family-given/given-family + } + \ExecuteBibliographyOptions{gbnamefmt} + + % + % 增加标签对齐选项 + % + % right是默认的右对齐,left是左对齐,gb7714-2015是项对齐方式 + \DeclareBibliographyOption[string]{gbalign}[right]{% + \ifstrequal{#1}{right}{\setcounter{gbalignlabel}{0}}{} + \ifstrequal{#1}{left}{\setcounter{gbalignlabel}{1}}{} + \ifstrequal{#1}{center}{\setcounter{gbalignlabel}{2}}{} + \ifstrequal{#1}{gb7714-2015}{\setaligngbstyle}{} + } + } + {% 针对biblatex<3.3版本的选项设置 + % 增加不同语言排序的切换选项 + % numeric样式,不使用该选项,这里给出仅为兼容性考虑 + % v1.0q,20190307,hzz + % + \DeclareBibliographyOption{gblanorder}[chineseahead]{} + + % + % 增加序号标签格式处理选项 + % v1.0l,20180623,hzz + % + \DeclareBibliographyOption{gbbiblabel}[bracket]{% + \csuse{gbbiblabelopt@#1} + } + \ExecuteBibliographyOptions{gbbiblabel} + + % + % 增加姓名大小写格式处理选项 + % + \DeclareBibliographyOption{gbnamefmt}[uppercase]{% + \ifstrequal{#1}{uppercase}{\setcounter{gbnamefmtcase}{0}}{}% + \ifstrequal{#1}{lowercase}{\setcounter{gbnamefmtcase}{1}}{}% + \ifstrequal{#1}{givenahead}{\setcounter{gbnamefmtcase}{2}}{}%given-family + \ifstrequal{#1}{familyahead}{\setcounter{gbnamefmtcase}{3}}{} + \ifstrequal{#1}{pinyin}{\setcounter{gbnamefmtcase}{4}}{}%family-given + \ifstrequal{#1}{reverseorder}{\setcounter{gbnamefmtcase}{5}}{}%family-given/given-family + } + \ExecuteBibliographyOptions{gbnamefmt} + + % + % 增加标签对齐选项 + % + % 原理方法:right是默认的右对齐,left是左对齐,gb7714-2015无效,仍然为右对齐模式, + % 因为在这种biblatex低版本中,舍弃了list类环境后,会出错。 + % 注意:texlive2015中的3.0版中的DeclareBibliographyOption选项没有类型说明 + \DeclareBibliographyOption{gbalign}[right]{% + \ifstrequal{#1}{right}{\setcounter{gbalignlabel}{0}}{} + \ifstrequal{#1}{left}{\setcounter{gbalignlabel}{1}}{} + \ifstrequal{#1}{center}{\setcounter{gbalignlabel}{2}}{} + \ifstrequal{#1}{gb7714-2015}{}{} + } + } + + +% +% 针对biblatex<3.3版本的选项设置,比如texlive2015中的3.0版 +% +\defversion{3.0}{opt}{ + \ExecuteBibliographyOptions{ + firstinits=true, %名字有缩写,参考3.1.2.3 Internal + } +} +% +% 针对3.3<=biblatex<3.5版本的选项设置,比如texlive2016中的3.4版 +% +\defversion{3.4}{opt}{ + \ExecuteBibliographyOptions{ + giveninits=true, %名字有缩写,参考3.1.2.3 Internal + } +} +% +% 针对3.7<=biblatex<=3.9版本的选项设置,比如texlive2017中的3.7版 +% +\defversion{3.7}{opt}{ + \ExecuteBibliographyOptions{ + giveninits=true, + urldate =edtf, %iso8601 + eventdate =edtf, + } +} +% +% 针对3.10<=biblatex版本的选项设置,比如texlive2018中的3.11版 +% +\defversion{3.10}{opt}{ + \ExecuteBibliographyOptions{ + giveninits=true, + urldate =gb7714-2015, %iso,iso8601,edtf + eventdate =gb7714-2015, + } +} + +% +% 根据biblatex版本信息,选择选项设置 +% +% 原理方法:如下这种选择机制能自动兼容更新的版本,但对于老版本 +% 必须要把情况列全。 +\iftoggle{iftlfive}{\switchversion{3.0}{opt}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{opt}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{opt}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{opt}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlnine}{\switchversion{3.10}{opt}}{}%biblatex=3.10 +\iftoggle{iftlatest}{\switchversion{3.10}{opt}}{}%biblatex最新3.11 + + +%===================================================================== +% 设置本地化字符串 +%===================================================================== + % + % 新建当地化字符串,用来记录“等”字符、“和”字符 + % + \NewBibliographyString{andotherscn} + \NewBibliographyString{andothersincitecn} + \NewBibliographyString{andothersincite} + \NewBibliographyString{andcn} + \NewBibliographyString{andothersjp} + \NewBibliographyString{andotherskr} + \NewBibliographyString{andjp} + \NewBibliographyString{andkr} + \NewBibliographyString{andincitecn} + \NewBibliographyString{andincite} + \NewBibliographyString{volumecn} + \NewBibliographyString{numbercn} + \NewBibliographyString{serialcn} + \NewBibliographyString{incn} + \NewBibliographyString{mathesiscn} + \NewBibliographyString{phdthesiscn} + \NewBibliographyString{editorcn} + \NewBibliographyString{editorscn} + + + + % + % 修改一些当地化字符串 + % + % 原理方法:直接利用当地化格式english修改出一些中文的格式,具体修改内容参考english.lbx文件 + % 当然也可以增加比如上面定义的andotherscn + % 注意:在lbx文件和bbx文件中定义本地字符串的不同语法,两个参数和一个参数的区别 + + \DefineBibliographyStrings{english}{ + bibliography = {\str@bibliography}, + references = {\str@references}, + bytranslator= {\str@bytranslator},%\addperiod,%将trans. by 改成 译\addcomma\ + and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 + andcn = {\addcomma},%and本地化字符串的中文对应词 + andincitecn = {\addcomma},%将标注中的分开,便于与文献表中的区分 + andincite = {\addcomma}, + %andothers = {et al.},%将超过3个人名的省略,et al.改成为 等 + andotherscn = {\str@andotherscn},%将超过3个人名的省略,et al.改成为 等 + andothersincitecn={\str@andotherscn},%将标注中的分开,便于与文献表中的区分 + andothersincite={et al\adddot}, + backrefpage = {\str@backrefpage:}, + backrefpages = {\str@backrefpages:}, + in={in\intitlepunct}, + volumecn={\str@volumecn}, + numbercn={\str@numbercn}, + serialcn={\str@serialcn}, + andothersjp={他}, + andotherskr={외}, + andjp={和}, + andkr={和}, + incn={\str@incn\addcolon\addspace}, + mathesiscn={\str@mathesiscn}, + phdthesiscn={\str@phdthesiscn}, + editorscn={\str@editorcn}, + editorcn={\str@editorcn}, +} + + % + % 增加两个命令用于临时的局部的修改本地化字符串 + % 其中\setlocalbibstring修改缩写字符串,setlocalbiblstring修改长字符串 + % 注意使用时因为是局部修改,因此要将其与需要修改的引用命令放在一个编组符号内 + % v1.0t,hzz,20190525 + \newcommand{\setlocalbibstring}[2]{% + \csdef{abx@sstr@#1}{#2}} + \newcommand{\setlocalbiblstring}[2]{% + \csdef{abx@lstr@#1}{#2}} + +%===================================================================== +% 动态数据修改 +%===================================================================== +% +% 各层次的数据映射和动态修改 +% +% 原理方法: +% 1. 进行语言包括中英文判断,并设置和记录,比如记录到userf,usere中 +% 2. 增加文献标识符如[M],[J]等,对一些容易混淆的域进行设置以增强兼容性 +% 3. \DeclareSourcemap命令对于biblatex3.11以下版本只能出现一次,3.11版开始支持多个 +% 4. \DeclarestyleSourcemap在biblatex v3.7版开始可以支持出现多次 +% 5. 把作者和译者信息准确的记录到userf,usere中,用于后面判断是否是cjk字符。 +% 注意:这里用userf,usere而不是namee,namef,是因为只有把name列表转成域,才能有效读取姓名中的字符, +% 如果用namee,namef,name信息会自动解析,所以就不能为cjk判断提供需要的信息 +% +% 不同的文献类型使用相同的驱动输出可以有5种方法: +% 1. 是数据源层的映射,将其它类型转换为某一要使用驱动的类型 +% 2. 是样式层映射,也是将其它类型转换为某一要使用驱动的类型 +% 3. 是驱动层映射,也是将其它类型转换为某一要使用驱动的类型 +% 4. 定义驱动类型别名DeclareBibliographyAlias,将其它类型定义为某一要使用驱动的类型的别名 +% 驱动别名定义本质上是做了驱动层映射 +% 5. 直接定义不同的类型的驱动,但驱动内容相同。 +% +% 关于数据映射和驱动使用的考虑如下: +% 1. 为避免利用biber输出bib文件时的数据变动,尽量不在数据源层映射做类型转换 +% 2. 为减少代码量,尽量少做内容相同的不同类型驱动 +% 3. 因此类型相关的处理主要在样式层映射、驱动层映射、驱动别名 +% 4. 由于biblatex默认做的驱动别名处理可能增加一些信息比如masterthesis转thesis时增加的type +% 可以在样式层映射做某些需要避免这种默认处置的转换 +% 5. 当没有避免默认行为的需求时,全部采用驱动别名的方式处理,等价于驱动层的映射 +% +% 文献类型和驱动考虑如下: +% 1. 连续出版物及析出文献有其特殊性,因此考虑两类periodical和article +% newpaper映射为article,并以note域做区分特殊处理 +% 2. 专著和专著中的析出文献是主要的类型,因此考虑book和inbook +% standard映射为book或inbook,并以note域做区分特殊处理 +% collection和proceedings基本与book类似,因此做book驱动别名处理 +% incollection和inproceedings基本与inbook类似,因此做inbook驱动别名处理 +% 3. 专利类型有其特殊性,考虑patent类型 +% 4. 电子资源类型有其特殊性,考虑online类型 +% 5. 报告类型与book有点类似,出版项处理与book一样,但有时又要有修改和更新日期 +% 因此考虑用一种类型来输出,使用report类型 +% 6. 手册/学位论文等类型与book有点类似,但对于出版项处理时,有缺省时,直接省略, +% 同时有version和edition的区别,因此考虑用一种类型来输出,使用manual类型 +% 7. 包括报告,学位论文在内的其它所有的类型,都做一个判断,当没有出版项时, +% 且存在网址信息时,将其转换为online类型输出,否则都做为manual类型输出。 +% 8. 备选类型misc当存在网址时直接转换为online,由于howpublished域可用于描述 +% 更多的信息,因此不存在网址时,独立做一个备选格式 +% 9. 出版项主要以如下方式处理: +% (a) location+institution+date 仅用于连续出版物 +% (b)publisher+location+date 用于需要完整输出出版项的类型,比如book,collection,proceedings,in*,report +% (c)institution+location+date 用于出版项缺失时不输出的类型,包括manual,thesis,archive等其他类型 +% (d)printlist{insitution} 用于电子资源,仅输出出版者或组织,为数据映射方便,本来默认的organization域转换为用insitution输出。 +% (e) 不输出,主要用于连续出版物析出的文献 +% 10. 日期以如下方式处理: +% date 由于存在biblatex选项,因此通过选项控制,数据源为date解析数据或year +% urldate 由于存在biblatex选项,因此通过选项控制,输出到日,且用[]包围,数据源为urldate +% newsdate 用于公告日期,公开日期或新闻日期,输出到日,但无包围符号,数据源为date +% modifydate 用于更新或修改日期,输出到日,且用()包围,数据源为date或enddate或eventdate + + +\DeclareSourcemap{ +\maps[datatype=bibtex]{% + \map{%当没有作者时将editor转成author + \pernottype{inbook}%因为in系列中editor可能用来表示bookauthor,所以排除 + \pernottype{inproceedings} + \pernottype{incollection} + \pernottype{periodical}%因为peridical直接使用editor,所以排除 + %注意notfield在低版本biblatex中没有 + %\step[notfield=author,final]%当author不存在,将editor复制给author + \step[fieldsource=editor,fieldtarget=author]%并删除editor + } + \map{%当没有作者时将translator转成author + \pernottype{inbook} + \pernottype{inproceedings} + \pernottype{incollection} + %\step[notfield=author,final]%当author不存在,将translator复制给author + \step[fieldsource=translator,fieldtarget=author]%并删除translator + } + \map{%让address和location同步,biblatex中address是location的别名 + %因此输出的时候只有location信息,但处理过程中是可以存在address的。 + %\step[notfield=address,final] + \step[fieldsource=location,final] + \step[fieldset=address,origfieldval] + } + \map{%让address和location同步 + %\step[notfield=location,final] + \step[fieldsource=address,final] + \step[fieldset=location,origfieldval] + } + \map{%处理在bib文件用mark标记文献类型标识符的情况 + \step[fieldsource=mark,final] + \step[fieldset=usera, origfieldval] + } + \map{%处理在bib文件中直接给出文献的姓名格式为lowercase的情况 + \step[fieldsource=nameformat,match=lowercase,final] + \step[fieldset=namefmtid,fieldvalue={1}] + } + \map{%处理在bib文件中直接给出文献的姓名格式为givenahead的情况 + \step[fieldsource=nameformat,match=givenahead,final] + \step[fieldset=namefmtid,fieldvalue={2}] + } + \map{%处理在bib文件中直接给出文献的姓名格式为familyahead的情况 + \step[fieldsource=nameformat,match=familyahead,final] + \step[fieldset=namefmtid,fieldvalue={3}] + } + \map{%处理在bib文件中直接给出文献的姓名格式为pinyin的情况 + \step[fieldsource=nameformat,match=pinyin,final] + \step[fieldset=namefmtid,fieldvalue={4}] + } + \map{%根据article确定文献类型标识符 + \pertype{article} + \step[fieldset=usera, fieldvalue={J}] + } + \map{%根据periodical确定文献类型标识符 + \pertype{periodical} + \step[fieldset=usera, fieldvalue={J}] + \step[fieldsource=author] %有时会把author和editor混淆,处理后使用editor + \step[fieldset=editor, origfieldval] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{%根据增加一个新闻报纸的类型newspaper确定文献类型标识符 + \pertype{newspaper} + \step[fieldset=usera, fieldvalue={N}] + \step[fieldset=note, fieldvalue=news]%因为没有专门的驱动,记录note方便映射为article后判断 + } + \map{%对应增加的一个数据库类型database确定文献类型标识符 + \pertype{database} + \step[fieldset=usera, fieldvalue={DB}] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{%对应增加的一个数据集类型dataset确定文献类型标识符 + \pertype{dataset} + \step[fieldset=usera, fieldvalue={DS}]% + \step[fieldsource=publisher] %有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{%对应增加的一个软件类型software确定文献类型标识符 + \pertype{software} + \step[fieldset=usera, fieldvalue={CP}] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{%对应增加的一个舆图类型map确定文献类型标识符 + \pertype{map} + \step[fieldset=usera, fieldvalue={CM}]% + \step[fieldsource=publisher] %有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{%对应增加的一个档案类型archive确定文献类型标识符 + \pertype{archive} + \step[fieldset=usera, fieldvalue={A}] + \step[fieldsource=publisher] %有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{%因为misc类型本身就是没有类型,而不像其它文献有明确的类型,所以 + %当misc类型带有网址时,直接将其转换为online类型 + \pertype{misc} + \step[fieldsource=url,final] + \step[typesource=misc,typetarget=online] + } + \map{%对应增加的一个备选类型misc确定文献类型标识符 + \pertype{misc} + \step[fieldset=usera, fieldvalue={Z}]% + } + \map{ + \pertype{book} + \pertype{inbook} + \step[fieldset=usera, fieldvalue={M}] + \step[fieldsource=version] %有时会把version和edition混淆,处理后直接用edition + \step[fieldset=edition, origfieldval] + } + \map{%兼容老的standard类型,确定文献类型标识符 + \pertype{standard} + \step[fieldset=usera, fieldvalue={S}] + \step[fieldset=note, fieldvalue=standard]%因为没有专门的驱动,记录note方便映射为book和inbook后判断 + } + \map{ + \pertype{patent} + \step[fieldset=usera, fieldvalue={P}] + } + \map{ + \pertype{inproceedings} + \pertype{conference}%兼容老的conference类型 + \step[fieldset=usera, fieldvalue={C}] + \step[fieldsource=institution]%有时会把publisher和institution混淆,处理后使用publisher + \step[fieldset=publisher, origfieldval] + } + \map{ + \pertype{proceedings} + \step[fieldset=usera, fieldvalue={C}] + \step[fieldsource=institution]%有时会把publisher和institution混淆,处理后使用publisher + \step[fieldset=publisher, origfieldval] + } + \map{ + \pertype{incollection} + \step[fieldset=usera, fieldvalue={G}] + \step[fieldsource=institution]%有时会把publisher和institution混淆,处理后使用publisher + \step[fieldset=publisher, origfieldval] + } + \map{ + \pertype{collection} + \step[fieldset=usera, fieldvalue={G}] + \step[fieldsource=institution]%有时会把publisher和institution混淆,处理后使用publisher + \step[fieldset=publisher, origfieldval] + } + \map{ + \pertype{report} + \pertype{techreport}%兼容老的techreport类型 + \step[fieldset=usera, fieldvalue={R}] + \step[fieldsource=institution]%有时会把publisher和institution混淆,处理后使用publisher + \step[fieldset=publisher, origfieldval] + } + \map{ + \pertype{thesis} + \pertype{mastersthesis}%兼容老的mastersthesis和phdthesis类型 + \pertype{phdthesis} + \step[fieldset=usera, fieldvalue={D}] + \step[fieldsource=publisher]%有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{online} + \pertype{electronic}%兼容老的electronic类型 + \pertype{www}%兼容老的www类型 + \step[fieldset=usera, fieldvalue={EB}] + \step[fieldsource=publisher]%有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval]%因为online的出版项处理类似手册 + \step[fieldsource=organization]%有时会把organization和institution混淆,处理后使用institution,以增强兼容性 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{manual} + \step[fieldset=usera, fieldvalue={A}] + \step[fieldsource=edition]%有时会把version和edition混淆,处理后使用version + \step[fieldset=version, origfieldval] + \step[fieldsource=publisher]%有时会把publisher和institution混淆,处理后使用institution + \step[fieldset=institution, origfieldval] + \step[fieldsource=organization]%有时会把organization和institution混淆,处理后使用institution,以增强兼容性 + \step[fieldset=institution, origfieldval] + } + \map{ + \pertype{unpublished} + \step[fieldset=usera, fieldvalue={Z}] + } + \map[overwrite]{%用于处理zotero从cnki导出中文文献姓名中存在逗号的情况 + \step[fieldsource={author}, match=\regexp{([\x{2FF0}-\x{9FA5}])\,\s*}, replace=\regexp{$1}] + }% + \map[overwrite]{%用于处理zotero从cnki导出中文文献姓名中存在逗号的情况 + \step[fieldsource={editor}, match=\regexp{([\x{2FF0}-\x{9FA5}])\,\s*}, replace=\regexp{$1}] + }% + \map[overwrite]{%用于处理zotero从cnki导出中文文献姓名中存在逗号的情况 + \step[fieldsource={translator}, match=\regexp{([\x{2FF0}-\x{9FA5}])\,\s*}, replace=\regexp{$1}] + }% + \map[overwrite]{%用于处理zotero从cnki导出中文文献姓名中存在逗号的情况 + \step[fieldsource={bookauthor}, match=\regexp{([\x{2FF0}-\x{9FA5}])\,\s*}, replace=\regexp{$1}] + }% + \map{%处理一些用year表示date的情况 + %这样处理将会设置date域,并使得labeldatesource变为空,因为date的前缀为空(如果是urldate,那么labeldatesource就是url)。 + %同时date域会被biblatex自动解析为year,month,day,并且覆盖原来的year信息 + \step[fieldsource=year] + \step[fieldset=date, origfieldval] + } + \map{%将entrykey放入keywords中用于后期使用 + \step[fieldsource=entrykey] + \step[fieldset=keywords, origfieldval] + } + \map{%文献题名的中文判断,将信息保存到userd中,避免因为标签生成原因导致title域被清除而产生问题 + \step[fieldsource=title, match=\regexp{[\x{2FF0}-\x{9FA5}]},final]% + \step[fieldset=userd, fieldvalue={chinese}] + } + \map{\step[fieldsource=title,match=\regexp{[\x{0100}-\x{017F}]},final]%\x80-\xFF + \step[fieldset=userd,fieldvalue={french}]%法语,0080开始到00ff的字符没法匹配有点奇怪 + } + \map{% + \step[fieldsource=title,match=\regexp{[\x{0400}-\x{052F}]},final] + \step[fieldset=userd,fieldvalue={russian}]%俄语 + } + \map{% + \step[fieldsource=title,match=\regexp{[\x{3040}-\x{30FF}\x{31F0}-\x{31FF}]},final] + \step[fieldset=userd,fieldvalue={japanese}]%日语 + } %确定形式后可增加类似andotherscn这样的本地化字符串处理 + \map{% + \step[fieldsource=title,match=\regexp{[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]},final] + \step[fieldset=userd,fieldvalue={korean}]%韩语 + } + \map{%将没有设置userd,且存在title域的默认设置为英文 + \step[fieldsource=title,final] + \step[fieldset=userd,fieldvalue={english}] + } + \map{%作者的中文判断 + \step[fieldsource=author, match=\regexp{[\x{2FF0}-\x{9FA5}]},final] + \step[fieldset=userf, fieldvalue={chinese}] + } + \map{\step[fieldsource=author,match=\regexp{[\x{0100}-\x{017F}]},final]%\x80-\xFF + \step[fieldset=userf,fieldvalue={french}]%法语,0080开始到00ff的字符没法匹配有点奇怪 + } + \map{% + \step[fieldsource=author,match=\regexp{[\x{0400}-\x{052F}]},final] + \step[fieldset=userf,fieldvalue={russian}]%俄语 + } + \map{% + \step[fieldsource=author,match=\regexp{[\x{3040}-\x{30FF}\x{31F0}-\x{31FF}]},final] + \step[fieldset=userf,fieldvalue={japanese}]%日语 + } %确定形式后可增加类似andotherscn这样的本地化字符串处理 + \map{% + \step[fieldsource=author,match=\regexp{[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]},final] + \step[fieldset=userf,fieldvalue={korean}]%韩语 + } + \map{%将没有设置userf,且存在author域的默认设置为英文 + \step[fieldsource=author,final] + \step[fieldset=userf,fieldvalue={english}] + } + \map{%译者的中文判断 + \step[fieldsource=translator, match=\regexp{[\x{2FF0}-\x{9FA5}]},final] + \step[fieldset=usere, fieldvalue={chinese}] + } + \map{\step[fieldsource=translator,match=\regexp{[\x{0100}-\x{017F}]},final]%\x80-\xFF + \step[fieldset=usere,fieldvalue={french}]%法语,0080开始到00ff的字符没法匹配有点奇怪 + } + \map{% + \step[fieldsource=translator,match=\regexp{[\x{0400}-\x{052F}]},final] + \step[fieldset=usere,fieldvalue={russian}]%俄语 + } + \map{% + \step[fieldsource=translator,match=\regexp{[\x{3040}-\x{30FF}\x{31F0}-\x{31FF}]},final] + \step[fieldset=usere,fieldvalue={japanese}]%日语 + } %确定形式后可增加类似andotherscn这样的本地化字符串处理 + \map{% + \step[fieldsource=translator,match=\regexp{[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]},final] + \step[fieldset=usere,fieldvalue={korean}]%韩语 + } + \map{%将没有设置usere,且存在translator域的默认设置为英文 + \step[fieldsource=translator,final] + \step[fieldset=usere,fieldvalue={english}] + } + \map{%编者的中文判断 + \step[fieldsource=editor, match=\regexp{[\x{2FF0}-\x{9FA5}]},final]%直接匹配cjk字符,unicode编码位置从2FF0到9FA5 + \step[fieldset=userc, fieldvalue={chinese}] + } + \map{\step[fieldsource=editor,match=\regexp{[\x{0100}-\x{017F}]},final]%\x80-\xFF + \step[fieldset=userc,fieldvalue={french}]%法语,0080开始到00ff的字符没法匹配有点奇怪 + } + \map{% + \step[fieldsource=editor,match=\regexp{[\x{0400}-\x{052F}]},final] + \step[fieldset=userc,fieldvalue={russian}]%俄语 + } + \map{% + \step[fieldsource=editor,match=\regexp{[\x{3040}-\x{30FF}\x{31F0}-\x{31FF}]},final] + \step[fieldset=userc,fieldvalue={japanese}]%日语 + } %确定形式后可增加类似andotherscn这样的本地化字符串处理 + \map{% + \step[fieldsource=editor,match=\regexp{[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]},final] + \step[fieldset=userc,fieldvalue={korean}]%韩语 + } + \map{%将没有设置userc,且存在editor域的默认设置为英文 + \step[fieldsource=editor,final] + \step[fieldset=userc,fieldvalue={english}] + } + \map{%编者的中文判断 + \step[fieldsource=bookauthor, match=\regexp{[\x{2FF0}-\x{9FA5}]},final]%直接匹配cjk字符,unicode编码位置从2FF0到9FA5 + \step[fieldset=userb, fieldvalue={chinese}] + } + \map{\step[fieldsource=bookauthor,match=\regexp{[\x{0100}-\x{017F}]},final]%\x80-\xFF + \step[fieldset=userb,fieldvalue={french}]%法语,0080开始到00ff的字符没法匹配有点奇怪 + } + \map{% + \step[fieldsource=bookauthor,match=\regexp{[\x{0400}-\x{052F}]},final] + \step[fieldset=userb,fieldvalue={russian}]%俄语 + } + \map{% + \step[fieldsource=bookauthor,match=\regexp{[\x{3040}-\x{30FF}\x{31F0}-\x{31FF}]},final] + \step[fieldset=userb,fieldvalue={japanese}]%日语 + } %确定形式后可增加类似andotherscn这样的本地化字符串处理 + \map{% + \step[fieldsource=bookauthor,match=\regexp{[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]},final] + \step[fieldset=userb,fieldvalue={korean}]%韩语 + } + \map{%将没有设置userc,且存在editor域的默认设置为英文 + \step[fieldsource=bookauthor,final] + \step[fieldset=userb,fieldvalue={english}] + } + \map{\step[fieldsource=userd,final]%userd存在则用根据标题的语言设定language + \step[fieldset=language,origfieldval]%本身language存在则不设定 + } + \map{\step[fieldsource=userf,final]%userd不存在,而userf存在则根据author的语言设定language + \step[fieldset=language,origfieldval] + }%如果没有作者和标题,那么剩下的最可能有意义的只有网址了,而网址通常是英文的,因此不用再进一步对其它域进行判断了。 + \map{%将没有设置的language设置成en,即认为不是中文的就是英文的。 + \step[fieldset=language,fieldvalue={english}] + } + \map{%一条文献的语言已经设定在language域中,由于出版项相关宏中使用userd判断, + %所以将一条文献的主体语言设定到userd中,本身前面userd已经设定,但没有处理无标题的情况, + %这里的处理等价于没有标题时,利用作者的语言设定userd,再没有作者,则默认用英文设定userd + \step[fieldsource=language] + \step[fieldset=userd,origfieldval] + } + \map{%当文献给出language域时,设置文献要使用的本地化字符串的语言 + \step[fieldsource=language,match=\regexp{(e|E)(n|N)(g|G)(l|L)(i|I)(s|S)(h|H)},final] + \step[fieldset=langid,fieldvalue={english}] + } + \map{ + \step[fieldsource=language,match=\regexp{(r|R)(u|U)(s|S)(s|S)(i|I)(a|A)(n|N)},final] + \step[fieldset=langid,fieldvalue={russian}] + } + \map{% + \step[fieldsource=language,match=\regexp{(f|F)(r|R)(e|E)(n|N)(c|C)(h|H)},final] + \step[fieldset=langid,fieldvalue={french}] + } + \map{% + \step[fieldsource=language,match=\regexp{(c|C)(h|H)(i|I)(n|N)(e|E)(s|S)(e|E)},final]%中日韩语目前都用english, + \step[fieldset=langid,fieldvalue={english}] + } + \map{% + \step[fieldsource=language,match=\regexp{(j|J)(a|A)(p|P)(a|A)(n|N)(e|E)(s|S)(e|E)},final]%中日韩语目前都用english, + \step[fieldset=langid,fieldvalue={english}] + } + \map{% + \step[fieldsource=language,match=\regexp{(k|K)(o|O)(r|R)(e|E)(a|A)(n|N)},final]%中日韩语目前都用english, + \step[fieldset=langid,fieldvalue={english}] + } +} +} + + +% +% 修改输入的参考文献数据,样式层的操作 +% +% 原理方法:因为biblatex3.0版的map不使用foreach选项,所以需要一个一个写,以处理特殊字符 +\defversion{3.0}{map}{ + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map{%尝试未定义数据模型的standard类型映射为其他类型book或inbook, + %standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + %因为可能要映射两种类型,所以不能在驱动层处理,因为要做判断 + \step[fieldsource=booktitle,final]%当存在booktitle域是映射为inbook + \step[typesource=standard, typetarget=inbook, final] + } + \map{%剩下的全部映射为book + \step[typesource=standard, typetarget=book, final] + } +% \map{%先于标准样式的driver层映射,以取消type设置 +% \step[typesource=mastersthesis, typetarget=thesis, final] +% %\step[fieldset=type, fieldvalue=mathesis] +% } +% \map{%先于标准样式的driver层映射,以取消type设置 +% \step[typesource=phdthesis, typetarget=thesis, final] +% %\step[fieldset=type, fieldvalue=phdthesis] +% } + \map{%先于标准样式的driver层映射,以取消type设置 + \step[typesource=techreport, typetarget=report, final] + %\step[fieldset=type, fieldvalue=techreport] + } + \map{% + \pertype{report} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=report,typetarget=online] + \step[fieldset=note,fieldvalue={report}] + } + \map{% + \pertype{thesis} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=thesis,typetarget=online] + } + \map{% + \pertype{manual} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=manual,typetarget=online] + } + \map{% + \pertype{unpublished} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=unpublished,typetarget=online] + } + \map{% + \pertype{database} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=databasetypetarget=online] + } + \map{% + \pertype{dataset} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=dataset,typetarget=online] + } + \map{% + \pertype{software} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=software,typetarget=online] + } + \map{% + \pertype{map} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=map,typetarget=online] + } + \map{% + \pertype{archive} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=archive,typetarget=online] + } + \map[overwrite]{%这里还必须有overwrite,注意不同版本存在差异,比如texlive2015变16后biber有变化(20161207修改正确) + \step[fieldsource=note, final]%将note域信息复制给keywords,用于输出时容易区分标准和报纸 + \step[fieldset=keywords, fieldvalue={,}, append] + \step[fieldset=keywords, origfieldval, append] + } + \map[overwrite]{%title,booktitle,journaltitle,journal,publisher,address,location,institution,organization + \step[fieldsource={title}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={journaltitle}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={journal}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={publisher}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={address}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={location}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={institution}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\#}, replace=\regexp{$1\\\#}] + } + \map[overwrite]{ + \step[fieldsource={booktitle}, match=\regexp{([^\\])\%}, replace=\regexp{$1\\\%}] + } + } + } +} + +% +% 修改输入的参考文献数据,样式层的操作 +% +% 原理方法:biblatex3.4以上版本 +\defversion{3.4}{map}{ + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map{%尝试未定义数据模型的standard类型映射为其他类型book或inbook, + %standard类型在blx-dm中有出现,但仅定义了类型,域和约束等都没有定义 + %因为可能要映射两种类型,所以不能在驱动层处理,因为要做判断 + \step[fieldsource=booktitle,final]%当存在booktitle域是映射为inbook + \step[typesource=standard, typetarget=inbook, final] + } + \map{%剩下的全部映射为book + \step[typesource=standard, typetarget=book, final] + } +% \map{%先于标准样式的driver层映射,以取消type设置 +% \step[typesource=mastersthesis, typetarget=thesis, final] +% %\step[fieldset=type, fieldvalue=mathesis] +% } +% \map{%先于标准样式的driver层映射,以取消type设置 +% \step[typesource=phdthesis, typetarget=thesis, final] +% %\step[fieldset=type, fieldvalue=phdthesis] +% } + \map{%先于标准样式的driver层映射,以取消type设置 + \step[typesource=techreport, typetarget=report, final] + %\step[fieldset=type, fieldvalue=techreport] + } + \map{% + \pertype{report} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=report,typetarget=online] + \step[fieldset=note,fieldvalue={report}] + } + \map{% + \pertype{thesis} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=thesis,typetarget=online] + } + \map{% + \pertype{manual} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=manual,typetarget=online] + } + \map{% + \pertype{unpublished} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=unpublished,typetarget=online] + } + \map{% + \pertype{database} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=databasetypetarget=online] + } + \map{% + \pertype{dataset} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=dataset,typetarget=online] + } + \map{% + \pertype{software} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=software,typetarget=online] + } + \map{% + \pertype{map} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=map,typetarget=online] + } + \map{% + \pertype{archive} + %biblatex3.7以下版本用如下方式来替代,address和location已在sourcemap中同步 + \step[fieldset=location,fieldvalue={}] + \step[fieldsource=location,notmatch=\regexp{.},final]%地址不存在且存在url那么转变为online + %3.7以上版本用notfield + %\step[notfield=address,final]%当address不存在则继续 + \step[fieldsource=url,final]%地址不存在且存在url那么转变为online + \step[typesource=archive,typetarget=online] + } + \map[overwrite]{%这里还必须有overwrite,注意不同版本存在差异,比如texlive2015变16后biber有变化(20161207修改正确) + \step[fieldsource=note, final]%将note域信息复制给keywords,用于输出时容易区分标准和报纸 + \step[fieldset=keywords, fieldvalue={,}, append] + \step[fieldset=keywords, origfieldval, append] + } + \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,address,location,institution,organization}]{ + \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\#}, replace=\regexp{$1\\\#}] + } + \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,address,location,institution,organization}]{ + \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\%}, replace=\regexp{$1\\\%}] + } + \map[overwrite, foreach={title,booktitle,journaltitle,journal,publisher,% + address,location,institution,organization}]{ + \step[fieldsource=\regexp{$MAPLOOP}, match=\regexp{([^\\])\x26}, replace=\regexp{$1\\\x26}] + } + } + } +} + +\iftoggle{iftlfive}% + {\switchversion{3.0}{map}}%%当采用biblatex<=3.2版本时 + {\switchversion{3.4}{map}}%%当采用3.3<=biblatex版本时 + +% +%驱动别名等价于驱动层映射 +% +\DeclareBibliographyAlias{newspaper}{article}% +\DeclareBibliographyAlias{inproceedings}{inbook}%会议论文文献类型驱动 +\DeclareBibliographyAlias{conference}{inbook}%会议论文文献类型驱动 +\DeclareBibliographyAlias{incollection}{inbook}%文集中析出文献类型驱动 +\DeclareBibliographyAlias{collection}{book}%%文集类型驱动 +\DeclareBibliographyAlias{proceedings}{book}%会议论文集文献类型驱动 +\DeclareBibliographyAlias{thesis}{manual}%学位论文驱动 +\DeclareBibliographyAlias{unpublished}{manual}%其它类型驱动 +\DeclareBibliographyAlias{database}{manual} +\DeclareBibliographyAlias{dataset}{manual} +\DeclareBibliographyAlias{software}{manual} +\DeclareBibliographyAlias{map}{manual} +\DeclareBibliographyAlias{archive}{manual} + + + +%===================================================================== +% 参考文献表环境 +%===================================================================== +% +% 列表格式 +% +% 增加一个\bibitemindent尺寸用于控制list环境的itemindent +% v1.0l,20180615,hzz +\setlength{\bibhang}{\biblabelsep}% +\newlength{\bibitemindent} +\setlength{\bibitemindent}{0pt} + + +\defbibenvironment{bibliography} + {\list + {\printtext[labelnumberwidth]{% + \printfield{labelprefix}% + \printfield{labelnumber}}} + {\setlength{\labelwidth}{\labelnumberwidth}% + \setlength{\labelsep}{\biblabelsep}% + \setlength{\leftmargin}{\bibhang}% + \addtolength{\leftmargin}{\labelnumberwidth}% + \setlength{\itemindent}{\bibitemindent}% + \setlength{\itemsep}{\bibitemsep}% + \setlength{\parsep}{\bibparsep}}% + \renewcommand*{\makelabel}[1]{\hss##1}} + {\endlist} + {\item} + +% +% 顺序编码制-标签对齐方式处理 +% +% 原理方法:利用选项提供的计数器数值做选择 +% 左对齐,右对齐为list环境下的处理,此时list环境的\labelwidth只能设置一个,是最宽标签的宽度 +% 项对齐则是在段落环境下做的处理。 +% 左对齐时,参考文献各项内容对齐,序号标签与参考文献项内容的间距可变 +% 右对齐时,参考文献各项内容对齐,序号标签与参考文献项内容的间距相等,标签与页边距离可变 +% 项对齐时,序号标签贴在页边,序号标签与参考文献项内容的间距相等 +% 修改序号标签格式为: +% \DeclareFieldFormat{shorthandwidth}{\mkbibbrackets{#1}} %源来自numeric.BBX +% \DeclareFieldFormat{labelnumberwidth}{\ttfamily\mkbibbrackets{#1}\hfill} +\DeclareFieldFormat{labelnumberwidth}{% +\ifcase\value{gbalignlabel}%右对齐,整个标签为右对齐 + \mkgbnumlabel{#1}% +\or%左对齐,整个标签为左对齐 + \mkgbnumlabel{#1}\hfill% +\or%中间对齐,比如:序号数字居于[]中间 + \hfil\mkgbnumlabel{\hfill#1\hfill}\hfil% +\fi} + +% +% 修改序号标签格式为以各条参文献为基础进行对齐的方式,即序号与条目内容间隔相等的方式。 +\def\setaligngbstyle{% +\def\blx@bibitem##1{% + \blx@ifdata{##1} + {\begingroup + \blx@getdata{##1}% + \blx@bibcheck + \iftoggle{blx@skipentry}{}{% + \blx@setdefaultrefcontext{##1}% + \global\let\blx@noitem\@empty + \blx@setoptions@type\abx@field@entrytype + \blx@setoptions@entry + \blx@thelabelnumber + \addtocounter{instcount}\@ne + \blx@initsep + \blx@namesep + \csuse{blx@item@\blx@theenv}\relax +% \blx@initsep %移动到上面去,恢复bibnamesep等的作用机制 +% \blx@namesep + \csuse{blx@hook@bibitem}% + \blx@execute + \blx@initunit + \blx@anchor + \blx@beglangbib + \bibsentence + \blx@pagetracker + \blx@driver\abx@field@entrytype + \blx@postpunct + \blx@endlangbib}% + \par\endgroup}%这里增加了一个\par + {}} +\newlength{\lengthid} +\newlength{\lengthlw} +\newcommand{\itemcmd}{% +\settowidth{\lengthid}{\mkgbnumlabel{\printfield{labelnumber}}} +\addtolength{\lengthid}{\biblabelsep} +\setlength{\lengthlw}{\textwidth} +\addtolength{\lengthlw}{-\lengthid} +\addvspace{\bibitemsep}%恢复\bibitemsep的作用 +%\parshape 2 0em \textwidth \lengthid \lengthlw +\hangindent\lengthid +\mkgbnumlabel{\printfield{labelnumber}}% +\hspace{\biblabelsep}} +% +% 简单的段落环境 +\defbibenvironment{bibliography} +{\begingroup\setlength{\parindent}{0em}} +{\endgroup} +{\itemcmd}} + + +%===================================================================== +% 设置单元或块等的标点 +%===================================================================== +\renewrobustcmd*{\bibinithyphendelim}{\addhighpenspace}%用于处理姓名中名部分存在-的情况,比如ZHANG Yu-xin +\renewcommand*{\subtitlepunct}{\addcolon\addspace} %修改标题和其它标题信息间的标点,来源biblatex.def, +% +% 利用set实现的多语言文献不同语言间的分隔符 +% 20170411,双语之间用newline替换par,避免采用gb7714-2015的项对齐方式第二语言间分段导致没有缩进 +% +% 原理方法:set方法可以参考3.11.5 Entry Sets,4.11.1 Entry Sets +% 这里调整一下两种语言参考文献的间隔,源来自biblatex.def +\renewcommand*{\entrysetpunct}{\adddot\newline\nobreak} +\renewcommand*{\bibpagespunct}{\addcolon\addthinspace}%%页码引用格式的修改,修改为用冒号 +%\renewcommand{\relateddelim}{}%\par + +%===================================================================== +% 修改域的格式,重定义域的输出宏 +%===================================================================== +% +% 新增文献类型标识符的格式 +% []前的nobreak,从GB4.1节的例子看不应该加,所以去掉 +% 但因为考虑到cjk字符和[]之间可能添加空格,所以仍然加上 +% 而[]中间的内容,从4.6.2节的例子看也是可以分割的,因此内部的nobreak也可以去掉 +% +\DeclareFieldFormat{gbtypeflag}{% +\iftoggle{bbx:url}% + {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\nobreak\printtext{[}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{\texttt{/}\thefield{medium}}]}}% + {\nobreak\printtext{[}\nobreak#1\nobreak\printtext{\texttt{/}OL]}}% + }% + {\ifentrytype{online}% + {\nobreak\printtext{[}\nobreak#1\nobreak\printtext{\texttt{/}OL]}}% + {\nobreak\printtext{[}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{\texttt{/}\thefield{medium}}]}}% + }% +} + +% +% 新增用于报纸的文献类型标识符的格式 +% +\DeclareFieldFormat{gbtypeflagn}{%用于报纸newspaper +\iftoggle{bbx:url}% + {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\nobreak\printtext{[}\nobreak N\printtext{\iffieldundef{medium}{}{\texttt{/}\thefield{medium}}]}\nobreak}% + {\nobreak\printtext{[}\nobreak N\printtext{\texttt{/}OL]}\nobreak}% + }% + {\nobreak\printtext{[}\nobreak N\printtext{\iffieldundef{medium}{}{\texttt{/}\thefield{medium}}]}\nobreak}% +} + +% +% 新增用于标准的文献类型标识符的格式 +% +\DeclareFieldFormat{gbtypeflags}{%用于标准standard +\iftoggle{bbx:url}% + {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\nobreak\printtext{[}\nobreak S\printtext{\iffieldundef{medium}{}{\texttt{/}\thefield{medium}}]}\nobreak}% + {\nobreak\printtext{[}\nobreak S\printtext{\texttt{/}OL]}\nobreak}% + }% + {\nobreak\printtext{[}\nobreak S\printtext{\iffieldundef{medium}{}{\texttt{/}\thefield{medium}}]}\nobreak}% +} + +% +% 重设title等参考文献信息的输出格式 +% +% 原理方法:修改来自biblatex.def文件的原格式 +\newcommand{\bibtitlefont}{} +\newcommand{\bibauthorfont}{} +\newcommand{\bibpubfont}{} + +\DeclareFieldFormat{title}{#1\adddot\addthinspace} +\DeclareFieldFormat{journaltitle}{#1\isdot}%添加\isdot用于缩写名带点情况,将其转换为缩写点,便于标点的追踪 +\DeclareFieldFormat{issuetitle}{#1} +\DeclareFieldFormat{maintitle}{#1} +\DeclareFieldFormat{booktitle}{#1} +\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉 + [article,patent,thesis,unpublished] + {title}{#1\adddot\addthinspace}%\mkbibquote{#1\isdot} +\DeclareFieldFormat%将期刊等文献的标题中原来带的引号去掉 + [inbook,incollection,inproceedings] + {title}{#1}%\nopunct\unspace +\DeclareFieldFormat{url}{\url{#1}} %%url相关输出,url域修改如本行,源来自biblatex.def +\def\UrlFont{\rmfamily}%设置url字体为roman字体%\ttfamily +%\urlstyle{rm} %使用这句也一样 +\setcounter{biburlnumpenalty}{100} %让url可以在数字后断行 +\setcounter{biburlucpenalty}{100} %让url可以在大写字母后断行 +\setcounter{biburllcpenalty}{100} %让url可以在小写字母后断行 +\DeclareFieldFormat{doi}{% + \rmfamily{DOI}\addcolon\space + \ifhyperref + {\href{https://doi.org/#1}{\nolinkurl{#1}}} + {\nolinkurl{#1}}} +% +% 标题的字母大小写格式修改 +% +% 注意:修改标题的字母大小写,不能用前面的title的格式而要用titlecase +% 因为titlecase is applied to the contents of the field directly,title is not +%\DeclareFieldFormat{titlecase}{\MakeCapital#1}%重设标题格式,将其修改为首字母大写 +\DeclareFieldFormat{titlecase}{\iftoggle{bbx:titlelink}{% +\iffieldundef{url}{\MakeCapital#1}{% +\href{\thefield{url}}{#1}}}{\MakeCapital#1}}%重设标题格式,将其修改为首字母大写 +\DeclareFieldFormat{pages}{#1}%去掉前面引导页码的pp.等字符,\mkpageprefix[bookpagination]{#1} +\DefineBibliographyExtras{english}{\renewcommand*{\bibrangedash}{-}}%将页码间隔符替换会英文的短横线 + +\def\execgbfdfmtstd{%恢复到标准样式的设置 +\DeclareFieldFormat{title}{\mkbibemph{##1}} +\DeclareFieldFormat + [article,inbook,incollection,inproceedings,patent,thesis,unpublished] + {title}{\mkbibquote{##1\isdot}} +\DeclareFieldFormat + [suppbook,suppcollection,suppperiodical] + {title}{##1} +\DeclareFieldFormat{journaltitle}{\mkbibemph{##1}} +\DeclareFieldFormat{issuetitle}{\mkbibemph{##1}} +\DeclareFieldFormat{maintitle}{\mkbibemph{##1}} +\DeclareFieldFormat{booktitle}{\mkbibemph{##1}} +\DeclareFieldFormat{url}{\mkbibacro{URL}\addcolon\space\url{##1}} +\DeclareFieldFormat{titlecase}{##1} +\DeclareFieldFormat{pages}{\mkpageprefix[bookpagination]{##1}} +} + +% +% 文献标题后的标点问题 +% v1.0k,20180405,为texlive2017以上版本中的beamer兼容性做的处理,Hu Zhenzhen +% +% 原理方法:如下代码处理texlive2017以上版本中,beamer中文献的标题后出现两个点的情况: +% texlive2017以上的beamer中对macro{title}做了patch,正常情况下不会出现两个点的情况,但由于 +% 之前为了处理texlive2015,2016下的title格式添加了adddot,导致出现两个点的情况,而且也影响 +% 析出文献的//符号的输出,因此再次对macro{title}做patch消除beamer中做apptocmd时添加的\newunitpunct +\ifboolexpr{% + test{\iftoggle{iftlfive}} + or + test{\iftoggle{iftlsix}} + }{}% + {%texlive 2017对应iftlseven以上版本 + \@ifclassloaded{beamer}{ + \DeclareFieldFormat{title}{#1}% + \DeclareFieldFormat[article,patent,thesis,unpublished]{title}{#1} + \AtBeginDocument{% + \patchcmd{\abx@macro@title}{\newunitpunct}{}{}{}}}{} + } + + +% +% 修改译者位置格式 +% +% 原理方法:修改来自biblatex.def文件的bytranslator+others宏的格式 +\renewbibmacro*{bytranslator+others}{\bibauthorfont% + \ifnameundef{translator} + {} + {%\usebibmacro{bytranslator+othersstrg} + %\setunit{\addspace}% + \printnames[bytranslator]{translator}% + \clearname{translator}% + %从macro*{bytranslator+othersstrg}%中可以看到当地化字符串格式的引用前的代码处理 + %比如生成cotranslator等用于调用cotranslator所代表的当地化字符串 + \usebibmacro{bytranslator+othersstrg}%“译”的位置换到下面来,即放到译者后面。 + %\setunit{\addspace}% + \newunit}% + \usebibmacro{withothers}} + + +% +% 修改作者数量超过限定值,做省略时的处理格式 +% v1.0,20160701,hzz +% v1.0O,20190103,hzz,修改利用新定义的一个分隔符strandothersdelim +% +% 原理方法:判断作者或译者是否中文,若中文用字符等,否则用et al. 。 +\renewbibmacro*{name:andothers}{\bibauthorfont% + \ifboolexpr{ + test {\ifnumequal{\value{listcount}}{\value{liststop}}} + and + test \ifmorenames + }{\ifnumgreater{\value{liststop}}{1}% + {\finalandcomma}% + {}% +\printdelim{andothersdelim}\printdelim{strandothersdelim}% +}{%当是译者的时候需要特殊处理:从7.2节看等,译前面加逗号,但从示例看等和译同时出现时,译前的逗号没有,比如: +%袁训来, 陈哲, 肖书海, 等. +%胡泳, 范海燕, 译. +%潘惠霞, 魏婧, 杨艳, 等译. +\ifcurrentname{translator}{\addcomma\addthinspace}{}%为了实现上述第二个示例情况做的处理 +}} + + +% +% 修改省略作者后的本地化字符串,比如et al. +% v1.0o,20190103,hzz +% +% 原理方法:默认情况下判断作者或译者是否中文,若中文用字符andotherscn=“等”,否则用andothers=“et al.”。 +% 非默认情况,根据选项信息,选择选择强制中文或英文 +% 首先设置全局的,然后设置文献表中的,这一等价于将所有的cite命令环境都设置过了 +% 而不用对每一个引用命令单独设置,比如cite,parancite,textcite都设置 +\DeclareDelimFormat{strandothersdelim}{% + \edef\userfieldabcde{userd}% + \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}% + \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}% + \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}% + \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}% + \ifcase\value{gbbiblocalcase}% + \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andotherscn}}{}% + \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andotherskr}}{}% + \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andothersjp}}{}% + \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andothers}}{}% + \iffieldequalstr{\userfieldabcde}{french}{\bibstring{andothers}}{}% + \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{andothers}}{}% + \or% + \bibstring{andotherscn}% + \or% + \bibstring{andothers}% + \fi} + +% +% 修改最后一个作者前的字符串,比如 and +% v1.0o,20190103,hzz +% +% 原理方法:默认情况下判断作者或译者是否中文,若中文用字符andcn=“和”,否则用and=“and”。 +% 非默认情况,根据选项信息,选择选择强制中文或英文 +% 首先设置全局的,然后设置文献表中的,这一等价于将所有的cite命令环境都设置过了 +% 而不用对每一个引用命令单独设置,比如cite,parancite,textcite都设置 +\DeclareDelimFormat{finalnamedelim}{% + \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}% + \addspace% + \edef\userfieldabcde{userd}% + \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}% + \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}% + \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}% + \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}% + \ifcase\value{gbbiblocalcase}% + \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}% + \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}% + \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}% + \iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}% + \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}% + \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% +\space% + \or% + \bibstring{andcn}\space% + \or% + \bibstring{and}\space% + \fi} + + +% +% 重设title的输出 +% +% 20180425,v1.0k,为标题增加字体控制命令,Hu Zhenzhen +% 原理方法:将文献类型标识符输出出去,原输出来自biblatex.def文件 +% 利用toggle做标识符是否输出的判断 +\renewbibmacro*{title}{% + \ifboolexpr{% + test{\iffieldundef{title}}% + and + test{\iffieldundef{subtitle}}% + }% + {}% + {\printtext[title]{\bibtitlefont%增加字体控制命令 + \printfield[titlecase]{title}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct}% + \printfield[titlecase]{subtitle}}% + \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格 + {\setunit{\subtitlepunct}\printfield{titleaddon}}% + \iftoggle{bbx:gbtype}{% + \iffieldundef{note}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准 + {\iffieldequalstr{note}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准 + {\iffieldequalstr{note}{news}{\printfield[gbtypeflagn]{usera}}%判断是否为报纸 + {\printfield[gbtypeflag]{usera}}}%其它 + }}{}% + %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点 + %\newunit +}% +}} + +% +% 作者信息的输出格式 +% +% 20180425,v1.0k,为作者增加字体控制命令,Hu Zhenzhen +% 20180603,v1.0l,增加使用nameformat域来选择姓名格式 +\DeclareNameFormat{namefmtselected}{% +\iffieldundef{namefmtid}{}% +{\defcounter{gbnamefmtcase}{\thefield{namefmtid}}}% +\ifcase\value{gbnamefmtcase}% + \ifgiveninits + {\usebibmacro{name:gbuppercase} + {\namepartfamily} + {\namepartgiveni} + {\namepartprefix} + {\namepartsuffix}} + {\usebibmacro{name:gbuppercase} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% +\or + \ifgiveninits + {\usebibmacro{name:gblowercase} + {\namepartfamily} + {\namepartgiveni} + {\namepartprefix} + {\namepartsuffix}} + {\usebibmacro{name:gblowercase} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% +\or + \ifgiveninits + {\usebibmacro{name:given-family} + {\namepartfamily} + {\namepartgiveni} + {\namepartprefix} + {\namepartsuffix}} + {\usebibmacro{name:given-family} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% +\or + \ifgiveninits + {\usebibmacro{name:family-given} + {\namepartfamily} + {\namepartgiveni} + {\namepartprefix} + {\namepartsuffix}} + {\usebibmacro{name:family-given} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% +\or +\usebibmacro{name:gbpinyin} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}% +\or + \ifnumequal{\value{listcount}}{1} + {\ifgiveninits + {\usebibmacro{name:family-given} + {\namepartfamily} + {\namepartgiveni} + {\namepartprefix} + {\namepartsuffix}} + {\usebibmacro{name:family-given} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}% + \ifboolexpe{% + test {\ifdefvoid\namepartgiven} + and + test {\ifdefvoid\namepartprefix}} + {} + {\usebibmacro{name:revsdelim}}} + {\ifgiveninits + {\usebibmacro{name:given-family} + {\namepartfamily} + {\namepartgiveni} + {\namepartprefix} + {\namepartsuffix}} + {\usebibmacro{name:given-family} + {\namepartfamily} + {\namepartgiven} + {\namepartprefix} + {\namepartsuffix}}}% +\fi + \usebibmacro{name:andothers}} + +\DeclareNameAlias{default}{namefmtselected}%姓名的默认格式采用可选的模式 +\DeclareNameAlias{sortname}{default}% Used in the bibliography %family-given/given-family +\DeclareNameAlias{citename}{default}% Default used by \citename + +\DeclareDelimFormat[bib,biblist]{andothersdelim}{\addcomma\addspace} +%\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}% + +%GB/T 7714-2015 风格,全部大写 +\newbibmacro*{name:gbuppercase}[4]{\bibauthorfont% +\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 +\renewcommand*{\revsdnamepunct}{}% + \ifuseprefix% + {\usebibmacro{name:delim}{#3#1}% + \usebibmacro{name:hook}{#3#1}% + \ifdefvoid{#3}{}{% + \ifcapital% + {\mkbibnameprefix{\MakeCapital{#3}}\isdot}% + {\mkbibnameprefix{#3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{#2}{\mkbibnamefamily{\MakeCapital{#1}}}{\mkbibnamefamily{\MakeUppercase{#1}}}\isdot% + \ifdefvoid{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{\MakeUppercase{#2}}\isdot}%\MakeCapital + \ifdefvoid{#4}{}{\addcomma\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}%后缀前加逗号 + {\usebibmacro{name:delim}{#1}% + \usebibmacro{name:hook}{#1}% + \ifdefvoid{#2}{\mkbibnamefamily{\MakeCapital{#1}}}{\mkbibnamefamily{\MakeUppercase{#1}}}\isdot% + \ifboolexpe{% + test {\ifdefvoid{#2}} + and + test {\ifdefvoid{#3}}} + {}{\revsdnamepunct}% + \ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{\MakeUppercase{#2}}\isdot}%\MakeCapital + \ifdefvoid{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}% + \ifdefvoid{#4}{}{\addcomma\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}%%后缀前加逗号 +} + +%GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 +\newbibmacro*{name:gblowercase}[4]{\bibauthorfont% + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \ifuseprefix + {\usebibmacro{name:delim}{#3#1}% + \usebibmacro{name:hook}{#3#1}% + \ifdefvoid{#3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{#3}}\isdot} + {\mkbibnameprefix{#3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{#2}{\mkbibnamefamily{\MakeCapital{#1}}}{\mkbibnamefamily{{#1}}}\isdot% + \ifdefvoid{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamegiven{{#2}}\isdot}%\MakeCapital + \ifdefvoid{#4}{}{\addcomma\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}%后缀前加逗号 + {\usebibmacro{name:delim}{#1}% + \usebibmacro{name:hook}{#1}% + \ifdefvoid{#2}{\mkbibnamefamily{\MakeCapital{#1}}}{\mkbibnamefamily{{#1}}}\isdot% + \ifboolexpe{% + test {\ifdefvoid{#2}} + and + test {\ifdefvoid{#3}}} + {}{\revsdnamepunct}% + \ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{{#2}}\isdot}%\MakeCapital + \ifdefvoid{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot} + \ifdefvoid{#4}{}{\addcomma\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}%%后缀前加逗号 +} + +%中文常见风格,汉语拼音全拼模式 +\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% +\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\renewcommand*{\revsdnamepunct}{}%%来源biblatex.def +\renewrobustcmd*{\bibnamedelima}{\mbox{-}}% + \ifuseprefix + {\usebibmacro{name:delim}{#3#1}% + \usebibmacro{name:hook}{#3#1}% + \ifdefvoid{#3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{#3}}\isdot} + {\mkbibnameprefix{#3}\isdot}% + \ifprefchar{}{\bibnamedelimc}}% + \ifdefvoid{#2}{\mkbibnamefamily{\MakeCapital{#1}}}{\mkbibnamefamily{\MakeUppercase{#1}}}\isdot% + \ifdefvoid{#2}{}{\revsdnamepunct\bibnamedelimd\MakeSentenceCase{\mkbibnamegiven{#2}}\isdot}%\MakeCapital + \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}} + {\usebibmacro{name:delim}{#1}% + \usebibmacro{name:hook}{#1}% + \ifdefvoid{#2}{\mkbibnamefamily{\MakeCapital{#1}}}{\mkbibnamefamily{\MakeUppercase{#1}}}\isdot% + \ifboolexpe{% + test {\ifdefvoid{#2}} + and + test {\ifdefvoid{#3}}} + {} + {\revsdnamepunct}% + \ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{\MakeCapital{#2}}\isdot}%\MakeCapital + \ifdefvoid{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot} + \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}% +} + + +\@ifpackagelater{biblatex}{2016/03/27}%biblatex<3.2版的情况 + {}{ + %GB/T 7714-2015 风格,全部大写 + \renewbibmacro*{name:gbuppercase}[4]{\bibauthorfont% + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \ifuseprefix + {\usebibmacro{name:delim}{#3#1}% + \usebibmacro{name:hook}{#3#1}% + \ifblank{#3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{#3}}\isdot} + {\mkbibnameprefix{#3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + %\mkbibnamelast{#1}\isdot + \ifblank{#2}{\MakeCapital#1}{\mkbibnamelast{\MakeUppercase{#1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + %注意上一句\MakeCapital后面如果再跟一个{}包含#1,则没有效果,可能是包在里面少了一层展开 + %因为机构名通常包括在{}内,所以要多展开一次才行,所以这里去掉#1外面的{} + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{\MakeUppercase{#2}}\isdot}% + \ifblank{#4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{#4}\isdot}}%后缀前加逗号 + {\usebibmacro{name:delim}{#1}% + \usebibmacro{name:hook}{#1}% + %\mkbibnamelast{#1}\isdot %3.9.1 Generic Commands and Hooks,对姓重新处理,如下句: %\mkbibnamelast{\MakeUppercase{#1}} + \ifblank{#2}{\MakeCapital#1}{\mkbibnamelast{\MakeUppercase{#1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + %\mkbibnamelast{\MakeUppercase{#1}}\isdot + %\ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}%这句放到后面 + \ifblank{#2#3}{}{\revsdnamepunct}% + \ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{\MakeUppercase{#2}}\isdot}% + \ifblank{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}% + \addcomma\addspace% + \ifblank{#4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{#4}\isdot}%%后缀前加逗号 + }% + } + + %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 + \renewbibmacro*{name:gblowercase}[4]{\bibauthorfont% + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \ifuseprefix + {\usebibmacro{name:delim}{#3#1}% + \usebibmacro{name:hook}{#3#1}% + \ifblank{#3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{#3}}\isdot} + {\mkbibnameprefix{#3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + \ifblank{#2}{\MakeCapital#1}{\mkbibnamelast{{#1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + \ifblank{#2}{}{\revsdnamepunct\bibnamedelimd\mkbibnamefirst{{#2}}\isdot}% + \ifblank{#4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{#4}\isdot}}%后缀前加逗号 + {\usebibmacro{name:delim}{#1}% + \usebibmacro{name:hook}{#1}% + \ifblank{#2}{\MakeCapital#1}{\mkbibnamelast{{#1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + \ifblank{#2#3}{}{\revsdnamepunct}% + \ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{{#2}}\isdot}% + \ifblank{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}% + \addcomma\addspace% + \ifblank{#4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{#4}\isdot}%%后缀前加逗号 + }% + } + + %中文常见风格,汉语拼音全拼模式 + \renewbibmacro*{name:gbpinyin}[4]{\bibauthorfont% + \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 + \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \renewrobustcmd*{\bibnamedelima}{\mbox{-}}% + \ifuseprefix + {\usebibmacro{name:delim}{#3#1}% + \usebibmacro{name:hook}{#3#1}% + \ifblank{#3}{}{% + \ifcapital + {\mkbibnameprefix{\MakeCapital{#3}}\isdot} + {\mkbibnameprefix{#3}\isdot}% + \ifpunctmark{'}{}{\bibnamedelimc}}% + \ifblank{#2}{\MakeCapital#1}{\mkbibnamelast{\MakeUppercase{#1}}}\isdot%\MakeUppercase %\mkbibnamelast{\MakeUppercase{#1}} %\MakeSentenceCase + \ifblank{#2}{}{\revsdnamepunct\bibnamedelimd\MakeSentenceCase{\mkbibnamefirst{#2}}\isdot}% + \ifblank{#4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{#4}\isdot}} + {\usebibmacro{name:delim}{#1}% + \usebibmacro{name:hook}{#1}% + \ifblank{#2}{\MakeCapital#1}{\mkbibnamelast{\MakeUppercase{#1}}}\isdot %大写,参考4.6.4 Miscellaneous Commands,\MakeUppercase %\MakeSentenceCase + \ifblank{#2#3}{}{\revsdnamepunct}% + \ifblank{#2}{}{\bibnamedelimd\mkbibnamefirst{\MakeUppercase{#2}}\isdot}% + \ifblank{#3}{}{\bibnamedelimd\mkbibnameprefix{#3}\isdot}% + \addcomma\addspace% + \ifblank{#4}{}{\addcomma\addspace\bibnamedelimd\mkbibnameaffix{#4}\isdot}% + }% + } + + %%biblatex<3.2版的情况,姓名的处理格式带参数 + \DeclareNameFormat{namefmtselected}{% + \iffieldundef{namefmtid}{}% + {\defcounter{gbnamefmtcase}{\thefield{namefmtid}}}% + \ifcase\value{gbnamefmtcase}% + \iffirstinits + {\usebibmacro{name:gbuppercase}{#1}{#4}{#5}{#7}} + {\usebibmacro{name:gbuppercase}{#1}{#3}{#5}{#7}}% + \or + \iffirstinits + {\usebibmacro{name:gblowercase}{#1}{#4}{#5}{#7}} + {\usebibmacro{name:gblowercase}{#1}{#3}{#5}{#7}}% + \or + \iffirstinits + {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}} + {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}% + \ifblank{#3#5} + {} + {\usebibmacro{name:revsdelim}}% + \or + \iffirstinits + {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}} + {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}% + \or + \usebibmacro{name:gbpinyin}{#1}{#3}{#5}{#7}% + \or + \ifnumequal{\value{listcount}}{1} + {\iffirstinits + {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}} + {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}% + \ifblank{#3#5} + {} + {\usebibmacro{name:revsdelim}}} + {\iffirstinits + {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}} + {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}% + \fi + \usebibmacro{name:andothers}} +} + +% +% url和url日期格式 +% +\renewbibmacro*{url+urldate}{% + %\usebibmacro{url}%%更换url的位置,放到下面 + \iffieldundef{urlyear}% + {}{%\setunit*{\addspace}% + \usebibmacro{urldate}}% + \setunit{\addperiod\addspace}% + \usebibmacro{url}} +\renewbibmacro*{url}{\printfield{url}} + + + + +% +% 日期信息的输出格式,针对biblatex<3.7版本 +% +\defversion{3.4}{date}{ + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printfield{urlyear}% + \iffieldundef{urlmonth}{}{\bibrangedash\printfield{urlmonth}}% + \iffieldundef{urlday}{}{\bibrangedash\printfield{urlday}}\printtext{]}} + + \newbibmacro*{newsdate}{%%新增加一个公告日期,公开日期或新闻日期 + \iffieldundef{year}{}{\printfield{year}% + \iffieldundef{month}{}{\bibrangedash\printtext{\thefield{month}}% + \iffieldundef{day}{}{\bibrangedash\printfield{day}}}}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \ifboolexpr{% + test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{eventday}}% + }% + {}%更新或修改日期通常有day信息 + {\iffieldequalstr{year}{}{%替换\iffieldundef{year},因为year总是存在,但为空 + \iffieldundef{endyear}{% + \iffieldundef{eventyear}{}{\printtext{\mkbibparens{\printtext{\printfield{eventyear}}% + \iffieldundef{eventmonth}{}{\bibrangedash\thefield{eventmonth}}% + \iffieldundef{eventday}{}{\bibrangedash\printfield{eventday}}}}% + }% + }{% + \iffieldundef{endyear}{}{\printtext{\mkbibparens{\printtext{\printfield{endyear}}% + \iffieldundef{endmonth}{}{\bibrangedash\thefield{endmonth}}% + \iffieldundef{endday}{}{\bibrangedash\printfield{endday}}}}% + }% + }% + }% + {% + \iffieldundef{year}{}{\printtext{\mkbibparens{\printtext{\printfield{year}}% + \iffieldundef{month}{}{\bibrangedash\thefield{month}}% + \iffieldundef{day}{}{\bibrangedash\printfield{day}}}}% + }% + }% + }}% +} + +% +% 日期信息的输出格式,针对3.9>=biblatex>=3.7版本 +% +\defversion{3.7}{date}{ + \DeclareFieldFormat{urldate}{##1} + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + + % + % 专利的公告日期、或报纸的日期的输出宏 + % 20160701,v1.0,新增加 + % 20180405,v1.0k,为biblatexv3.7-3.9版本,出现多出点bug做处理,Hu Zhenzhen + % + % 原理方法:加上printtext避免破坏异步标点机制 + % + \newbibmacro*{newsdate}{% + \printtext{\blx@edtfdate{}{}}% + } + + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \ifboolexpr{% + test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{eventday}}% + }% + {}%更新或修改日期通常有day信息 + {\iffieldundef{year}{% + \iffieldundef{endyear}{\iffieldundef{eventyear}{}{\printtext{(}\printeventdate\printtext{)}}}% + {\printtext{(}\printenddate\printtext{)}}% + }{\iffieldequalstr{year}{}{%因为year存在,但为空 + }{\printtext{(}\blx@edtfdate{}{}\printtext{)}}% + }% + }}% +} + +% +% 日期信息的输出格式,针对biblatex>=3.10版本 +% +\defversion{3.10}{date}{ + \DeclareFieldFormat{urldate}{##1} + \renewbibmacro*{urldate}{% + \addthinspace\printtext{[}\printurldate\printtext{]}}%能用高层命令+选项尽量用命令(比如这里的\printurldate),而不用\blx@edtfdate这种更底层的命令 + + % + % 专利的公告日期、或报纸的日期的输出宏 + % 20160701,v1.0,新增加 + % 20180405,为biblatexv3.10版本,出现多出点bug做处理,Hu Zhenzhen + % + % 原理方法:加上printtext避免破坏异步标点机制 + % 本可以用\printdate,但由于date选项设置为year,所以仅会给出年份 + % 所以无法再用选项设置的方法,印象需要用底层的命令 + % 这里可以用\blx@isodate,但用\blx@gbdate试图避免版本判断 + \newbibmacro*{newsdate}{%% + \printtext{\blx@gbdate{}{}}%%\blx@isodate{}{}% + } + + % + \newbibmacro*{modifydate}{%新增加一个带括号的日期,用于表示电子资源的更新和修改日期,而公告日期则按日期格式 + \ifboolexpr{% + test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{eventday}}% + }% + {}%更新或修改日期通常有day信息 + {\iffieldundef{year}{% + \iffieldundef{endyear}{\iffieldundef{eventyear}{}{\printtext{(}\printeventdate\printtext{)}}}% + {\printtext{(}\printenddate\printtext{)}}% + }{\iffieldequalstr{year}{}{%因为year存在,但为空 + }{\printtext{(}\blx@gbdate{}{}\printtext{)}}% + }% + }}% +} + +% +% biblatex>v3.8版利用related实现双语文献的处理 +% +\defversion{3.8}{dblang}{ + %为了实现v3.8以上版本的双语文献,采用related的方法代替set方法,因为set方法已经无法实现了, + %因为set不再复制其第一个成员的信息。于是定义一个命令,用于动态的修改数据,即添加related域的信息 + %其中使用了\DeclareStyleSourcemap,但由于其只能出现在导言区中,因此\defdoublelangentry命令也只能出现在导言区中 + \newcommand{\defdoublelangentry}[2]{% + \edef\entrykeya{##1} + \edef\entrykeyb{##2} + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map{ + \step[fieldsource=entrykey, match=\entrykeya, final] + \step[fieldset=related, fieldvalue=\entrykeyb] + } + } + } + } +} + +% +% 关联文献间的分隔符 +% +\renewcommand{\relateddelim}{\adddot\newline\nobreak}%\par,而作者年样式不需要修改,因为没有项对齐的标签问题 + +% +% 关联文献的输出格式,针对3.9>=biblatex>=3.7版本 +% +% 原理方法:因为related宏中带有##了,所以无法封装到defversion中了。所以直接做判断 +% 下面这一段主要针对v3.8-3.10,因为我提问后,biblatex作者为3.11版增加了一个钩子控制relatedblock前的分隔符。 +\ifboolexpr{ +test{\iftoggle{iftleight}} +or +test{\iftoggle{iftlnine}} +}{\renewbibmacro*{related}{%standard.bbx + \ifboolexpr{ test {\iffieldundef{related}} or test {\ifrelatedloop} } + {} + {\usebibmacro{begrelated}% + \def\bbx@tempa{}% + \setcounter{bbx:relatedtotal}{0}% + \def\do##1{% + \entrydata{##1}{% + \ifrelatedloop + {} + {\stepcounter{bbx:relatedtotal}% + \gappto{\bbx@tempa}{##1,}}}}% + \docsvfield{related}% + \restorefield{related}{\bbx@tempa}% + \ifnumgreater{\value{bbx:relatedtotal}}{0} + {\listcsxadd{bbx:relatedloop}{\strfield{entrykey}}% + \iffieldundef{clonesourcekey} + {} + {\listcsxadd{bbx:relatedloop}{\strfield{clonesourcekey}}}% + \setcounter{bbx:relatedcount}{0}% + \def\do{% + \stepcounter{bbx:relatedcount}% + \ifnumgreater{\value{bbx:relatedcount}}{0}%这里从1改为0 + {\ifcsundef{relateddelim\strfield{relatedtype}} + {\printtext{\relateddelim}} + {\printtext{\csuse{relateddelim\strfield{relatedtype}}}}} + {}}% + \ifbibmacroundef{related:\strfield{relatedtype}} + {\appto{\do}{\usebibmacro{related:default}}} + {\appto{\do}{\usebibmacro*{related:\strfield{relatedtype}}}}% + \iffieldformatundef{related:\strfield{relatedtype}} + {\def\bbx@tempa{related}} + {\def\bbx@tempa{related:\strfield{relatedtype}}}% + \iffieldformatundef{relatedstring:\strfield{relatedtype}} + {\def\bbx@tempb{relatedstring:default}} + {\def\bbx@tempb{relatedstring:\strfield{relatedtype}}}% + \printtext[\bbx@tempa]{% + \usebibmacro{begrelatedloop}% + \iffieldundef{relatedstring} + {\ifboolexpr{ + test {\ifnumgreater{\value{bbx:relatedtotal}}{1}} + and + test {\ifbibxstring{\thefield{relatedtype}s}} + } + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedtype}s}}} + {\iffieldbibstring{relatedtype} + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedtype}}}} + {}}} + {\iffieldbibstring{relatedstring} + {\printtext[\bbx@tempb]{% + \bibstring[\mkrelatedstring]{\thefield{relatedstring}}}} + {\printfield[\bbx@tempb]{relatedstring}}}% + \docsvfield{related}% + \usebibmacro{endrelatedloop}}}% + {}% + \usebibmacro{endrelated}}} +}{} + +% +% 关联文献块前的分隔符,针对biblatex>3.11 +% +% 原理方法:因为增加了begrelateddelim钩子,所以不需要重定义related输出宏 +\defversion{3.11}{related}{ +\renewcommand{\begrelateddelim}{\adddot\newline\nobreak} +} + +\iftoggle{iftlfive}{\switchversion{3.4}{date}}{}%biblatex<=3.2 +\iftoggle{iftlsix}{\switchversion{3.4}{date}}{}%3.3<=biblatex<=3.6 +\iftoggle{iftlseven}{\switchversion{3.7}{date}}{}%biblatex=3.7 +\iftoggle{iftleight}{\switchversion{3.7}{date}\switchversion{3.8}{dblang}}{}%3.8<=biblatex<=3.9 +\iftoggle{iftlnine}{\switchversion{3.10}{date}\switchversion{3.8}{dblang}}{}%biblatex=3.10 +\iftoggle{iftlatest}{\switchversion{3.10}{date}\switchversion{3.8}{dblang}\switchversion{3.11}{related}}{}%biblatex最新3.11 + +% +% 调整doi+eprint+url格式 +% 2016.07.01 byhzz +% 2019.05.01 byhzz 在eprint前增加一个空格 +% 原理方法:源来自standard.bbx,因为页码后面直接跟引用日期,没有标点所以去掉其中的标点。 +\renewbibmacro*{doi+eprint+url}{% +% \iftoggle{bbx:doi}%把doi的位置放到url后面 +% {\printfield{doi}} +% {}% + %\newunit\newblock + \iftoggle{bbx:eprint} + {\iffieldundef{eprint}{}{\newunit\usebibmacro{eprint}}} + {}% + %\newunit\newblock + \iftoggle{bbx:url} + {\usebibmacro{url+urldate}} + {} + \newunit\newblock + \iftoggle{bbx:doi} + {\printfield{doi}} + {}} + +% +% 调整页码的格式,即chapter+pages格式 +% +\renewbibmacro*{chapter+pages}{% +\iftoggle{bbx:gbstrict}{}{% + \printfield{chapter}}% + \iffieldundef{pages}{}{%这里增加一个判断,当没有页码时就不输出 + \setunit{\bibpagespunct}% + \printfield{pages}}% + %\newunit %这里的标点去掉 +} + +% +% 当location等出版项超过maxitem缩减后不再输出etal +% +\DeclareListFormat{location}{% + \usebibmacro{list:delim}{#1}% + #1\isdot} +\DeclareListAlias{institution}{location} +\DeclareListAlias{publisher}{location} + +% 新增一个样式用于输出连续出版物的地址,单位,时间, +% 用于periodical连续出版物的出版社和地址的处理 +% +% v1.0k,20180425,为出版信息增加字体控制命令,hzz +% %类似\newbibmacro*{publisher+location+date} +\newbibmacro*{location+institution+date}{\bibpubfont% +\iftoggle{bbx:gbpub}% +{\testCJKfirst{userd}% +\ifboolexpr{% +test {\iflistundef{location}} and test {\iflistundef{institution}}% +}{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress}\space :\space\str@nopublisher]}% +{\printtext{[S.l.\space :\space s.n.\adddot]}}% +}{% +\iflistundef{location}{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress]}}{\printtext{[S.l.\adddot]}}}% + {\printlist{location}}% +\addcolon\addspace% +\iflistundef{institution}{% +\iftoggle{ifCJKforgbt}{\printtext{[\str@nopublisher]}}{\printtext{\mkbibbrackets{s.n.}}}}% +{\printlist{institution}}}% +\setunit{\addcomma\addspace}% + %\usebibmacro{date}% + \printfield{year}% + \bibrangedash% + \iffieldundef{endyear}{}{\printfield{endyear}}% + \newunit}% +{\printlist{location}% + \iflistundef{institution}% + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{institution}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + \newunit}% +} +% +% 通用的出版社和地址的处理 +% +% 原理方法:当没有出版社地址时,直接判断title的信息是否是中文,若为中文,则写出版地不详,否则用英文的字符表示。 +% 事实上title对于每个文献来说是必须的,所以用它判断是最快的,而且一般标题和出版社的语言是一样的。 +% 注意标准standard类型,因为当没有出版项时直接省略,所以做特殊处理 +\renewbibmacro*{publisher+location+date}{\bibpubfont% +\iftoggle{bbx:gbpub}% +{\testCJKfirst{userd}% + \ifboolexpr{ test {\iflistundef{location}} and test {\iflistundef{publisher}} }% + {\iffieldequalstr{note}{standard}{}{\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress}\space :\space\str@nopublisher]}{\printtext{[S.l.\space :\space s.n.\adddot]}}}}% + {\iflistundef{location}{%\adddot + \iffieldequalstr{note}{standard}{}%%从gbt7714-2015标准第19页看到,标准存在出版项时输出,没有时完全省略。 + {\iftoggle{ifCJKforgbt}{\printtext{[\str@noaddress]}\addcolon\addspace}{\printtext{[S.l.\adddot]}\addcolon\addspace}}}% \bibstring{noaddress} + {\printlist{location}\addcolon\addspace}%%\addcolon\addspace% + \iflistundef{publisher}{% + \iffieldequalstr{note}{standard}{}% + {\iftoggle{ifCJKforgbt}{\printtext{[\str@nopublisher]}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}% + {\printtext{\mkbibbrackets{s.n.}}\setunit{\adddot\addspace}\setunit*{\addcomma\addspace}}}}% + {\printlist{publisher}}}% +\setunit*{\addcomma\addspace}%\addcomma\addspace% +\usebibmacro{date}%%\newunit %去掉这个标点 +}% +{\printlist{location}% + \iflistundef{publisher} + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{publisher}% + \setunit*{\addcomma\space}% + \usebibmacro{date}%%\newunit + }% +} + +% +% 修改了一个institution+location+date用于manual、report、thesis等类型 +% +% 20180425,v1.0k,增加了字体控制命令,hzz +% 20190105,v1.0o,加了一个编组避免\usebibmacro{date}把month和day信息去掉 +\renewbibmacro*{institution+location+date}{\bibpubfont%当没有institution时不处理。 +{\printlist{location}%%加了一个编组避免\usebibmacro{date}把month和day信息去掉 + \iflistundef{institution} + {\setunit*{\addcomma\space}} + {\setunit*{\addcolon\space}}% + \printlist{institution}% + \setunit*{\addcomma\space}% + \usebibmacro{date}% + %\newunit + }} + +% +% 对volume卷信息格式做出修改 +% v1.0o,20190105,hzz +% +\DeclareFieldFormat{volume}{% +\testCJKfirst{userd}% +\iftoggle{ifCJKforgbt}% +{\bibstring{serialcn}#1\bibstring{volumecn}}% +{\bibstring{volume}~#1}% +}% volume of a book +\DeclareFieldFormat[article,periodical]{volume}{#1}% volume of a journal + +% +% 对number册信息格式做出修改 +% v1.0o,20190105,hzz +% +\DeclareFieldFormat{number}{#1}% +\DeclareFieldFormat[book,collection,inbook,% +incollection,proceedings,inproceedings]{number}{% +\testCJKfirst{userd}% +\iftoggle{ifCJKforgbt}% +{\bibstring{serialcn}#1\bibstring{numbercn}}% +{#1}% +}% + +% +% 对edition版本信息格式做出修改 +% +\DeclareFieldFormat{edition}{\bibtitlefont%源来自biblatex.DEF +\testCJKfirst{userd}% +\iftoggle{ifCJKforgbt}% +{\ifinteger{#1}% +{\printtext{#1\str@edition}}% +{#1\isdot}}% +{\ifinteger{#1}% +{\mkbibordedition{#1}~\bibstring{edition}}% +{#1\isdot}}} + +% +% 对version的版本信息做出修改 +% +\DeclareFieldFormat{version}{\bibtitlefont%源来自biblatex.DEF +\testCJKfirst{userd}% +\ifinteger{#1}% +{\iftoggle{ifCJKforgbt}{\printtext{#1\str@edition}}% +{\mkbibordedition{#1}~\bibstring{version}}}% +{#1\isdot}} + +% +% 修改析出文献的文集的标题与附加标题间的符号 +% +\renewbibmacro*{booktitle}{% + \ifboolexpr{ + test {\iffieldundef{booktitle}} + and + test {\iffieldundef{booksubtitle}} + } + {} + {\printtext[booktitle]{\bibtitlefont% + \printfield[titlecase]{booktitle}% + \setunit{\subtitlepunct}% + \printfield[titlecase]{booksubtitle}}% + \newunit%标点换成下一句 + \setunit{\subtitlepunct}}% + \printfield{booktitleaddon}} + + +% +% 调整期刊名的格式 +% +% v1.0k,20180425,增加了字体控制命令,hzz +\renewbibmacro*{journal+issuetitle}{\bibpubfont%源来自standard.bbx + \usebibmacro{journal}% + %\setunit*{\addspace}% + \setunit*{\addcomma\addspace}%修改为增加一个逗号 + \iffieldundef{series} + {} + {\newunit + \printfield{series}% + \setunit{\addspace}}% + %\usebibmacro{volume+number+eid}% + %\setunit{\addspace}% + \usebibmacro{issue+date}% + %\setunit{\addcolon\space}% + \iffieldundef{volume}{}{\setunit{\addcomma\space}}% + %换成逗号和空格 + \usebibmacro{issue}% + \usebibmacro{volume+number+eid}%把卷期放到年份后面 + %\newunit + } + + + +% +% 调整期刊卷和期的格式 +% +\renewbibmacro*{volume+number+eid}{%源来自standard.bbx +\iftoggle{bbx:gbfieldstd}{% + \printfield{volume}% + \setunit*{\adddot}% + \printfield{number}% + \setunit{\addcomma\space}% + \printfield{eid}}{% + \printfield{volume}% + %\setunit*{\adddot}%去掉点号 + %\printfield{number}% + \iffieldundef{number}{}{\printtext{\mkbibparens{\printfield{number}}}}%增加一个圆括号 + \iffieldundef{eid}{}{% + \setunit{\addcomma\space}% + \printfield{eid}}}} + +% +% 调整期刊年份的格式 +% +\renewbibmacro*{issue+date}{%去掉括号 + \printtext{%去掉了[parens] + \iffieldundef{issue} + {%\usebibmacro{date} + \iffieldundef{note}{\usebibmacro{date}}%判断一下,是否是报纸 + {\iffieldequalstr{note}{news}{\usebibmacro{newsdate}}%判断是否为报纸 + {\usebibmacro{date}}% + }}% + {\iftoggle{bbx:gbstrict}{}{\printfield{issue}% + \setunit*{\addspace}}% + %\usebibmacro{date} + \iffieldundef{note}{\usebibmacro{date}}%判断一下,是否是报纸 + {\iffieldequalstr{note}{news}{\usebibmacro{newsdate}}%判断是否为报纸 + {\usebibmacro{date}}% + }}}% + %\newunit + } + +% +% 调整页码前的标点和去掉期刊文章等页码后面的标点 +% +\renewbibmacro*{note+pages}{%源来自standard.bbx + %\printfield{note}%不要note,note用来判断是否是报纸newspaper + \iffieldundef{pages}{}{ + \setunit{\bibpagespunct}% + \printfield{pages}}% + %\newunit + } + + +% +% 编者的符号修改一下 +% v1.0 2016-07-01 +% v1.0q 2019-03-01 hzz 修改editortype前的标点 +% +\renewbibmacro*{editor}{%源来自biblatex.DEF + \ifboolexpr{ + test \ifuseeditor + and + not test {\ifnameundef{editor}} + } + {\printnames{editor}% + \iffieldundef{editortype}%增加一个类型判断,用于存在editortype的情况 + {\setunit\addspace}%当没有editortype时,直接用句点 + {%\setunit{\addcomma\space}% + \usebibmacro{editorstrg}}% + %\clearname{editor} + }% + {}} + +% +% 编者类型做一修改 +% v1.0 2016-07-01 +% v1.0q 2019-03-01 hzz 修改editortype不同语言的不同本地化字符串 +% +\renewbibmacro*{editorstrg}{%源来自biblatex.DEF + \printtext[editortype]{% + \iffieldundef{editortype} + {% +% \ifboolexpr{ %这一段去掉,未定义编者类型情况下不处理 +% test {\ifnumgreater{\value{editor}}{1}} +% or +% test {\ifandothers{editor}} +% } +% {\bibstring{editors}} +% {\bibstring{editor}} + } + {\ifbibxstring{\thefield{editortype}} %定义编者类型情况下处理,以后根据需要修改 + {\ifboolexpr{ + test {\ifnumgreater{\value{editor}}{1}} + or + test {\ifandothers{editor}} + } + {\printdelim{streditortypes}} + {\printdelim{streditortype}}} + {\thefield{editortype}}}% + }} + +% +% 编者类型的本地化字符串输出 +% v1.0q 2019-03-01 hzz +% 能对不同条目类型作格式设置的域格式,能对不同环境做格式设置的分隔符 +% 能对不同文境作设置的包括排序,标签等 +% 这里因为考虑可能标注和文献表中存在不同,所以用分隔符来输出本地化字符串 +% +\DeclareDelimFormat{streditortypes}{% + \edef\userfieldabcde{userd}% + \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}% + \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}% + \ifcase\value{gbbiblocalcase}% + \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{\thefield{editortype}scn}}{}% + \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{\thefield{editortype}skr}}{}% + \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{\thefield{editortype}sjp}}{}% + \iffieldequalstr{\userfieldabcde}{english}{\addcomma\addthinspace\bibstring{\thefield{editortype}s}}{}% + \iffieldequalstr{\userfieldabcde}{french}{\addcomma\addthinspace\bibstring{\thefield{editortype}s}}{}% + \iffieldequalstr{\userfieldabcde}{russian}{\addcomma\addthinspace\bibstring{\thefield{editortype}s}}{}% + \or% + \bibstring{\thefield{editortype}scn}% + \or% + \addcomma\addthinspace\bibstring{\thefield{editortype}s}% + \fi} +% +\DeclareDelimFormat{streditortype}{% + \edef\userfieldabcde{userd}% + \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}% + \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}% + \ifcase\value{gbbiblocalcase}% + \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{\thefield{editortype}cn}}{}% + \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{\thefield{editortype}kr}}{}% + \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{\thefield{editortype}jp}}{}% + \iffieldequalstr{\userfieldabcde}{english}{\addcomma\addthinspace\bibstring{\thefield{editortype}}}{}% + \iffieldequalstr{\userfieldabcde}{french}{\addcomma\addthinspace\bibstring{\thefield{editortype}}}{}% + \iffieldequalstr{\userfieldabcde}{russian}{\addcomma\addthinspace\bibstring{\thefield{editortype}}}{}% + \or% + \bibstring{\thefield{editortype}cn}% + \or% + \addcomma\addthinspace\bibstring{\thefield{editortype}}% + \fi} + + +% +% bookauthor域的输出, +% v1.0q 2019-03-01 hzz +% 不再对editor和bookauthor做sourcemap,而是下面的宏内逻辑代替, +% 使得除使用bookauthor外也可以使用editor,便于在使用editor时使用editortype +\renewbibmacro*{bybookauthor}{% + \ifnameundef{bookauthor}% + {\ifnameundef{editor}% + {}% + {\ifnamesequal{author}{editor}% + {}{\usebibmacro{editor}}}% + }% + {\ifnamesequal{author}{bookauthor}% + {}{\printnames{bookauthor}}% + }% +} + +% +% 修改期刊的标题 +% +\renewbibmacro*{periodical}{%源来自biblatex.DEF + \iffieldundef{title} + {} + {\printtext[title]{\bibtitlefont% + \printfield[titlecase]{title}% + %\setunit{\subtitlepunct}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct} + \printfield[titlecase]{subtitle}}% + %}%把编组结束移到后面去 + \iftoggle{bbx:gbtype}{% + \iffieldundef{usera}{}{%在标题后直接给出文献标识字母 + \printfield[gbtypeflag]{usera}}}{} + }} + } + +% +% 期刊的标题做修改 +% +\renewbibmacro*{title+issuetitle}{%源来自standard.BBX + \usebibmacro{periodical}% + %\setunit*{\addspace}% + \setunit*{\adddot\addspace}%标点修改为句点 + \iffieldundef{series} + {} + {\newunit + \printfield{series}% + \setunit{\addspace}}% + \usebibmacro{periodical+issue}%将issue调整到上面来,并修改 +\iffieldundef{number}{}{%%进一步处理有范围的数字 + \multinumberparser{\thefield{number}}}% + \iffieldundef{volume}% + {\printfield{year}% + \printtext{\mkbibparens{\multinumberfirst}}% + \bibrangedash% + \iffieldundef{endyear}{}{\printfield{endyear}\printtext{\mkbibparens{\multinumbersecond}}}% + }% + {\multivolparser{\thefield{volume}}% + \printfield{year}% + \setunit{\addcomma\space}%将冒号修改为逗号 + \printtext{\multivolfirst}% + \printtext{\mkbibparens{\multinumberfirst}}% + \bibrangedash% + \iffieldundef{endyear}{}{% + \printfield{endyear}% + \setunit{\addcomma\space}%将冒号修改为逗号 + \printtext{\multivolsecond}% + \printtext{\mkbibparens{\multinumbersecond}}}% + }% + \setunit{\addcomma\space}% + \printfield{eid}% + \setunit{\addspace}% + %\usebibmacro{issue+date}% + %\setunit{\addcolon\space}% + \usebibmacro{issue}% + \newunit} + +% +% 新增一个样式用于调整期刊年份的格式,只打印年份 +% +\newbibmacro*{periodical+issue}{% + \printtext{%去掉了[parens] + \iffieldundef{issue} + {%\usebibmacro{date}%修改为下一句 + }% + {\printfield{issue}% + \setunit*{\addspace}% + %\usebibmacro{date}%修改为下一句 + }% + }% + %\newunit +} + +% +% 重设专利title的输出,将文献类型标识符输出出去 +% +\newbibmacro*{patenttitle}{%原输出来自biblatex.def文件 + \ifboolexpr{% + test{\iffieldundef{title}}% + and% + test{\iffieldundef{subtitle}}% + }% + {}% + {\printtext[title]{\bibtitlefont% + \printfield[titlecase]{title}% + \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题 + {}{\setunit{\subtitlepunct}% + \printfield[titlecase]{subtitle}}% + \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格 + {\setunit{\subtitlepunct}\printfield{titleaddon}}% + \setunit{\subtitlepunct}\printfield{number}%写专利号 + \iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}% + %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点 + %\newunit + }% +}% +} + + + +% +% 修改in:用于inbook、incollection、inproceedings等类型 +% 2018.04.20,v1.0k,renewed marco,by hzz +% 20190212,v1.0q,增加中英文区分,by hzz +% +% 原理方法:使用bibmacro{in:}改变了以前在driver中直接输出//的方式,同时也简化了标点控制。 +\renewbibmacro*{in:}{% + \iftoggle{bbx:gbpunctin}{\printtext{\texttt{//}\allowbreak}}%\addthinspace + {\setunit{\adddot\addspace}% + \iffieldequalstr{userd}{chinese}% + {\printtext{\bibstring{incn}}}% + {\printtext{\bibstring{in}}}% + }}%\newunit\newblock\intitlepunct + +% +% 修改type域的输出格式 +% 2019.02.12,v1.0q,byhzz +% 使其可以区分中英文输出不同的格式,比如博士论文英文输出PHD thesis,中文则是博士学位论文 +\DeclareFieldFormat{type}% +{\iffieldequalstr{userd}{chinese}% + {\ifbibxstring{#1cn}{\bibxstring{#1cn}}{#1}}% + {\ifbibstring{#1}{\bibstring{#1}}{#1}}% +} + +% +% 修改series域的输出格式 +% 2019.05.01,v1.0r,byhzz +\renewbibmacro*{series+number}{% + \printfield{series}% + %\setunit*{\addspace}% + %\printfield{number}% + %\newunit + } + +%===================================================================== +%设置驱动格式 +%===================================================================== +% +% book条目类的驱动 +% + \DeclareBibliographyDriver{book}{%源来自standard.bbx文件 + \usebibmacro{bibindex}% + \usebibmacro{begentry}% +\usebibmacro{author/editor+others/translator+others}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 +\usebibmacro{maintitle+title}% +\iftoggle{bbx:gbstrict}{}{% +\newunit +\printlist{language}% +\newunit\newblock% +\usebibmacro{byauthor}% +\newunit\newblock}% +\usebibmacro{byeditor+others}% +\newunit +\printfield{edition}% +\newunit\newblock%% +\iftoggle{bbx:gbstrict}{}{% +\iffieldundef{maintitle}% +{\printfield{volume}% +\printfield{part}}% +{}% +\newunit% +\printfield{volumes}% +\newunit\newblock% +\usebibmacro{series+number}}% +\newunit\newblock% +%\printfield{note}% +%\newunit\newblock% +\usebibmacro{publisher+location+date}% +%\newunit\newblock %这里标点去掉 +\usebibmacro{chapter+pages}% + \iffieldundef{url}{}{%当没有网址时也不输出 + \usebibmacro{modifydate}}%带括号的修改或更新日期, +\usebibmacro{doi+eprint+url}%从下面移动到上面来,因为gbt2015的url需直接放在页码后面。 + \newunit\newblock% + \printfield{pagetotal}% + \newunit\newblock% + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + + +% +% 期刊文章,连续出版物中的析出文献的格式 +% + \DeclareBibliographyDriver{article}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 + \usebibmacro{title}% + \iftoggle{bbx:gbstrict}{}{% + \newunit% + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{bytranslator+others}% + \newunit\newblock + \printfield{version}}% + \newunit\newblock + %\usebibmacro{in:}% 不使用in来表示期刊等连续出版物 + \usebibmacro{journal+issuetitle}% + %\newunit +% \usebibmacro{byeditor+others}% +% \newunit + \usebibmacro{note+pages}% + \iffieldequalstr{note}{news}{}{%当是新闻时不输出修改或更新日期 + \iffieldundef{url}{}{%当没有网址时也不输出 + \usebibmacro{modifydate}}}%带括号的修改或更新日期, + \usebibmacro{doi+eprint+url}%从后面移上来,调整url和页码之间的位置 + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{issn}} + {}% + \newunit\newblock + %\usebibmacro{doi+eprint+url}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + + + +% +% 连续出版物的驱动 +% + \DeclareBibliographyDriver{periodical}{%源来自standard.BBX + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{editor}% + %\setunit{\labelnamepunct}\newblock + \newunit\newblock %删除上面一行,添加这一行 + \usebibmacro{title+issuetitle}% + \newunit\newblock% + \usebibmacro{location+institution+date}%添加这一行用于输出地址,单位和时间 + \newunit\newblock%添加这一行 + \iftoggle{bbx:gbstrict}{}{% + \printlist{language}% + \newunit\newblock + \usebibmacro{byeditor}% + \newunit\newblock + \printfield{note}% + \newunit\newblock} + \iftoggle{bbx:isbn} + {\printfield{issn}} + {}% + \newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + +% +% 专利文献驱动 +% + \DeclareBibliographyDriver{patent}{%源来自standard.BBX + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 + %\usebibmacro{title}% + \usebibmacro{patenttitle}%给出专利专用的标题输出 + \iftoggle{bbx:gbstrict}{}{% + \newunit% + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}}% + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + %\printfield{number}%已放到patenttitle中处理 + \iflistundef{location} + {} + {\setunit*{\addspace}% + \printtext{%[parens] + \printlist[][-\value{listtotal}]{location}}}% + \newunit\newblock + \usebibmacro{byholder}% + \newunit\newblock + \printfield{note}% + \newunit\newblock + \usebibmacro{newsdate}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + + +% +% 在线文献驱动 +% +\DeclareBibliographyDriver{online}{%源来自standard.BBX + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/editor+others/translator+others}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 + \usebibmacro{title}% + \iftoggle{bbx:gbstrict}{}{% + \newunit% + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}% + \newunit\newblock + \printfield{note}}% + \newunit + \printfield{version}% + \newunit\newblock + %\printlist{organization}% + \printlist{institution}% + \newunit\newblock +\ifboolexpr{% +test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{eventday}}% +}{\usebibmacro{date}}% +{\usebibmacro{modifydate}}%修改或更新日期,为带括号的时间 + \usebibmacro{url+urldate}%从下面移上来 + \newunit\newblock + \iftoggle{bbx:eprint} + {\usebibmacro{eprint}} + {}% + \newunit\newblock + %\usebibmacro{url+urldate}% + %\newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + + +% +% 报告类型驱动 +% 当有网址无出版项时,用online输出 +% +\DeclareBibliographyDriver{report}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 + \usebibmacro{title}% + \iftoggle{bbx:gbstrict}{}{% + \newunit% + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}}% + \newunit\newblock + \usebibmacro{byeditor+others}%增加的译者信息 + \newunit\newblock + \printfield{type}% + \setunit*{\addspace}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{publisher+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + +% +% 论文、手册类型驱动 +% 2016-11-11,增加了译者信息 +% +\DeclareBibliographyDriver{manual}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 + \usebibmacro{title}% + \iftoggle{bbx:gbstrict}{}{% + \newunit% + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}}% + \newunit\newblock + \usebibmacro{byeditor+others}%增加的译者信息 + \newunit\newblock + \iftoggle{bbx:gbfieldtype}{% + \printfield{type}% + \setunit*{\addspace}}{}% + \printfield{number}% + \newunit\newblock + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + \iffieldundef{url}{}{%当没有网址时也不输出修改或更新日期 + \usebibmacro{modifydate}}%修改或更新日期为带括号的时间 + \usebibmacro{doi+eprint+url}% + \newunit + \printfield{pagetotal}% + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isrn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + +% +% 备选类型驱动 +% +% 利用biblatex的misc驱动 +\DeclareBibliographyDriver{misc}{% + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/editor+others/translator+others}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 + \usebibmacro{title}% +\iftoggle{bbx:gbstrict}{}{% + \newunit + \printlist{language}% + \newunit\newblock + \usebibmacro{byauthor}% + \newunit\newblock + \usebibmacro{byeditor+others}}% + \newunit\newblock + \printfield{howpublished}% + \newunit\newblock + \printfield{type}% + \newunit + \printfield{version}% + \newunit + \printfield{note}% + \newunit\newblock + \usebibmacro{institution+location+date}% + %\usebibmacro{organization+location+date}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}% + \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} + + +% +% 专著中的析出文献的格式修改 +% +\DeclareBibliographyDriver{inbook}{%源来自standard.bbx + \usebibmacro{bibindex}% + \usebibmacro{begentry}% + \usebibmacro{author/translator+others}% +\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点 +\usebibmacro{title}% +\usebibmacro{in:}% +%\printtext{\texttt{//}\addthinspace}% + \usebibmacro{bybookauthor}% + \ifnameundef{bookauthor}{% + \ifnameundef{editor}{}{\newunit}% + }{\newunit}%替换下一句 + %\newunit\newblock +\iffieldundef{series}{}{\usebibmacro{series+number}\setunit{\addcolon\addspace}}%为处理一些存在series的情况而增加 + \usebibmacro{maintitle+booktitle}% +\iffieldundef{volume}{}{\setunit{\addcolon\addspace}\printfield{volume}}% +\iffieldundef{number}{}{\setunit{\addcolon\addspace}\printfield{number}}%增加卷和册信息 + \newunit\newblock% +% \usebibmacro{byeditor+others}% +% \newunit\newblock + \printfield{edition}% + \newunit + \iftoggle{bbx:gbstrict}{}{% +% \iffieldundef{maintitle} +% {\printfield{volume}% +% \printfield{part}} +% {}% +% \newunit +% \printfield{volumes}% +% \newunit\newblock +% \usebibmacro{series+number} + }% + \newunit\newblock + %\printfield{note}% + %\newunit\newblock + \usebibmacro{publisher+location+date}% + %\newunit\newblock + \usebibmacro{chapter+pages}% + %\newunit\newblock + \usebibmacro{doi+eprint+url}%移到上面来 + \newunit\newblock + \iftoggle{bbx:isbn} + {\printfield{isbn}} + {}% + \newunit\newblock +% \usebibmacro{doi+eprint+url}% +% \newunit\newblock + \usebibmacro{addendum+pubstate}% + \setunit{\bibpagerefpunct}\newblock + \usebibmacro{pageref}% + \newunit\newblock + \iftoggle{bbx:related} + {\usebibmacro{related:init}% + \usebibmacro{related}} + {}% + \usebibmacro{finentry}\usebibmacro{annotation}} diff --git a/gb7714-2015.cbx b/gb7714-2015.cbx new file mode 100644 index 00000000..a62ca688 --- /dev/null +++ b/gb7714-2015.cbx @@ -0,0 +1,279 @@ +%% +%% --------------------------------------------------------------- +%% biblatex-gb7714-2015 --- A biblatex implementation of the +%% GBT7714-2015 citation style,numerical sequence +%% Maintained by huzhenzhen +%% E-mail: hzzmail@163.com +%% Released under the LaTeX Project Public License v1.3c or later +%% --------------------------------------------------------------- +%% +\def\versionofgbtstyle{2019/08/28 v1.0s} +\ProvidesFile{gb7714-2015.cbx}[\versionofgbtstyle biblatex citation style] + +% +% 加载标准样式 +% +\RequireCitationStyle{numeric-comp} %numeric + + +% +% 选项设置 +% +\ExecuteBibliographyOptions{ + autocite = superscript , + autopunct = true , + %sorting = none , + maxcitenames=1, + mincitenames=1, +} + +%textcite标注命令中的标点设置 +%\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}% + +% +% 定义一个上标方括号wrapper +% +\newcommand*\mkbibsuperbracket[1]{% + \mkbibsuperscript{\mkbibbrackets{#1}}% +} + +% 修改postnote的输出格式 +\DeclareFieldFormat{postnote}{#1} + +% +% 重定义cite命令 +% +% 方法:\DeclareCiteCommand{\cite}[\mkbibparens]{precode}{loopcode}{sepcode}{postcode} +% v1.0p版后将cite的处理方式修改为类似pagescite,而不再使用biblatex的标准方式 +\DeclareCiteCommand{\cite}[\mkbibsuperscript]%利用mkbibsuperbracket添加方括号 + {[\usebibmacro{cite:init}% + \usebibmacro{prenote}} + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]% + \printfield{postnote}} +% v1.0p 以前用的方式 +%\DeclareCiteCommand{\cite}[\mkbibsuperbracket]%利用mkbibsuperbracket添加方括号 +% {\usebibmacro{cite:init}% +% \usebibmacro{prenote}} +% {\usebibmacro{citeindex}% +% \usebibmacro{cite:comp}} +% {} +% {\usebibmacro{cite:dump}% +% \usebibmacro{postnote}} + +% +% 定义upcite命令 +% 20180604,v1.0l,hzz +% 20190409,v1.0r,hzz +% 方法:对supercite增加[] +\newrobustcmd*{\upcite}{% + \cite} + +% +% 重定义parencite命令,以满足标签带页码的国标要求 +% +\DeclareCiteCommand{\parencite}%[\mkbibbrackets] + {[\usebibmacro{cite:init}%] + \usebibmacro{prenote}}% + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {%[ + \usebibmacro{cite:dump}]% + \mkbibsuperscript{\printfield{postnote}}} + +% +% 新定义pagescite命令,以满足标签带页码的国标要求 +% +% 原理方法: +% 1.新增页码输出宏 +\newbibmacro*{postpages}{% + \iffieldundef{postnote} + {\printfield[postnote]{pages}} + {\printfield{postnote}}} +% 2.新增\pagescite引用命令 +\DeclareCiteCommand{\pagescite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 + {[\usebibmacro{cite:init}%]直接添加方括号 + \usebibmacro{prenote}% + } + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]% + \usebibmacro{postpages}} + +% +% 定义yearpagescite,为与ay样式兼容,等同于\pagescite +% +\DeclareCiteCommand{\yearpagescite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 + {[\usebibmacro{cite:init}%]直接添加方括号 + \usebibmacro{prenote}% + } + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]% + \usebibmacro{postpages}} + +% +% 定义\yearcite命令,为与ay样式兼容,且提供不输出页码的标签格式, +% +% 原理方法:等同于\pagescite,但不要页码 +\DeclareCiteCommand{\yearcite}[\mkbibsuperscript]%\mkbibbrackets,仍然用上标 + {[\usebibmacro{cite:init}%]直接添加方括号 + \usebibmacro{prenote}% + } + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]} + +% +% 定义\authornumcite命令,输出作者信息,然后在后面带上顺序编码 +% 20180427,v1.0k,增加,hzz +% gb7714样式新定义的命令都把cite放到最后,比如前面的pagescite,yearcite,这里的\authornumcite +% 区别于biblatex定义的命令都把cite放到前面,比如citeauthor等。 +%见numeric.CBX +\newbibmacro*{cite}{% + \printtext[bibhyperref]{% + \printfield{labelprefix}% + \printfield{labelnumber}% + \ifbool{bbx:subentry} + {\printfield{entrysetcount}} + {}}} +%见numeric.CBX,\DeclareCiteCommand{\cite}, +\DeclareCiteCommand{\authornumcite}%[\mkbibsuperscript] + {\usebibmacro{prenote}} + {\iffieldequalstr{userf}{cn}{\renewcommand*{\andothersdelim}{\addthinspace}}%\addthinspace + {\renewcommand*{\andothersdelim}{\addspace}}% + \printnames{labelname}\mkbibsuperscript{\mkbibbrackets{\usebibmacro{citeindex}% + \usebibmacro{cite}}}} + {\multicitedelim} + {\mkbibsuperscript{\printfield{postnote}}} + + +% +% 增加如下多个命令 +% 20190409,v1.0r,hzz +% 方法:利用newcommand或newrobustcmd命令进行定义 +% 注意\citet和\citep命令之所以不用newrobustcmd,是为避免加载natbib模块后产生冲突 +\DeclareCiteCommand{\citet}% + {\usebibmacro{prenote}} + {\iffieldequalstr{userf}{cn}{\renewcommand*{\andothersdelim}{\addthinspace}}%\addthinspace + {\renewcommand*{\andothersdelim}{\addspace}}% + \printnames{labelname}\mkbibsuperscript{\mkbibbrackets{\usebibmacro{citeindex}% + \usebibmacro{cite}}}} + {\multicitedelim} + {\mkbibsuperscript{\printfield{postnote}}} + + +\DeclareCiteCommand{\citep}[\mkbibsuperscript]%利用mkbibsuperbracket添加方括号 + {[\usebibmacro{cite:init}% + \usebibmacro{prenote}} + {\usebibmacro{citeindex}% + \usebibmacro{cite:comp}} + {} + {\usebibmacro{cite:dump}]% + \printfield{postnote}} + +\newrobustcmd*{\citetns}% + {\textcite} + +\newrobustcmd*{\citepns}% + {\parencite} + +\newrobustcmd*{\inlinecite}% + {\parencite} + +% +% 增加如下复数的命令,以符合biblatex的复数命令习惯 +% 20190430,v1.0r,hzz +% citec和citecs命令是实现了[1]-[3]这样的压缩形式。 +% authornumcites是常用命令authornumcite的复数形式 +\DeclareFieldFormat{labelbracket}{\mkbibbrackets{#1}} + +\newbibmacro*{citec:comp:comp}{% + \ifboolexpr{ + ( test {\iffieldundef{labelprefix}} and test {\ifundef\cbx@lastprefix} ) + or + test {\iffieldequals{labelprefix}{\cbx@lastprefix}} + } + {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}} + {\savefield{entrykey}{\cbx@lastkey}% + \savefield{labelnumber}{\cbx@lastnumber}% + \addtocounter{cbx@tempcnta}{1}} + {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}-1} + {} + {\usebibmacro{citec:dump}% + \ifnumgreater{\value{cbx@tempcntb}}{-1} + {\multicitedelim} + {}% + \printtext[bibhyperref]{% + \printfield{labelprefix}% + \printtext[labelbracket]{\printfield{labelnumber}}}}}} + {\usebibmacro{cite:comp:end}}% + \setcounter{cbx@tempcntb}{\thefield{labelnumber}}% + \savefield{labelprefix}{\cbx@lastprefix}} + +\newbibmacro*{citec:comp}{% + \addtocounter{cbx@tempcntb}{1}% + \iffieldundef{shorthand} + {\ifbool{bbx:subentry} + {\iffieldundef{entrysetcount} + {\usebibmacro{citec:comp:comp}} + {\usebibmacro{cite:comp:inset}}} + {\usebibmacro{citec:comp:comp}}} + {\usebibmacro{cite:comp:shand}}} + +\newbibmacro*{citec:dump}{% + \ifnumgreater{\value{cbx@tempcnta}}{0} + {\ifnumgreater{\value{cbx@tempcnta}}{1} + {\bibrangedash} + {\multicitedelim}% + \bibhyperref[\cbx@lastkey]{% + \ifdef\cbx@lastprefix + {\printtext[labelprefix]{\cbx@lastprefix}} + {}% + \printtext[labelbracket]{\cbx@lastnumber}}}%labelnumber + {}% + \setcounter{cbx@tempcnta}{0}% + \global\undef\cbx@lastprefix} + +%\DeclareCiteCommand{\citec}[\mkbibsuperscript]%[\mkbibbrackets] +% {\usebibmacro{cite:init}% +% \usebibmacro{prenote}} +% {\usebibmacro{citeindex}% +% \usebibmacro{citec:comp}} +% {} +% {\usebibmacro{citec:dump}% +% \usebibmacro{postnote}} + +%上面这个用于非压缩情况,这里考虑了压缩的情况 +\DeclareCiteCommand{\citec}[\mkbibsuperscript]% + {\ifnumless{\value{multicitecount}}{2} + {\usebibmacro{cite:init}% + \usebibmacro{prenote}} + {\iffieldundef{prenote} + {\iffieldundef{postnote} + {} + {\usebibmacro{citec:dump}% + \usebibmacro{cite:init}% + \setunit{\multicitedelim}}} + {\usebibmacro{citec:dump}% + \usebibmacro{cite:init}% + \setunit{\multicitedelim}% + \usebibmacro{prenote}}}} + {\usebibmacro{citeindex}% + \usebibmacro{citec:comp}} + {} + {\ifboolexpr{ test {\ifnumequal{\value{multicitecount}}{\value{multicitetotal}}} + or not test {\iffieldundef{postnote}}} + {\usebibmacro{citec:dump}% + \usebibmacro{postnote}} + {}} + +\DeclareMultiCiteCommand{\citecs}[\mkbibsuperscript]{\citec}{} + +\DeclareMultiCiteCommand{\authornumcites}[]{\authornumcite}{\multicitedelim} diff --git a/logos/resources/sjtu-logo-red.pdf b/logos/resources/sjtu-logo-red.pdf deleted file mode 100644 index b97b2708..00000000 Binary files a/logos/resources/sjtu-logo-red.pdf and /dev/null differ diff --git a/logos/sjtu-badge.pdf b/logos/sjtu-badge.pdf deleted file mode 120000 index b5421ff1..00000000 --- a/logos/sjtu-badge.pdf +++ /dev/null @@ -1 +0,0 @@ -./resources/sjtu-badge-blue.pdf \ No newline at end of file diff --git a/logos/sjtu-logo.pdf b/logos/sjtu-logo.pdf deleted file mode 120000 index 2af0b968..00000000 --- a/logos/sjtu-logo.pdf +++ /dev/null @@ -1 +0,0 @@ -./resources/sjtu-logo-black.pdf \ No newline at end of file diff --git a/logos/sjtu-name.pdf b/logos/sjtu-name.pdf deleted file mode 120000 index 5a4f2c19..00000000 --- a/logos/sjtu-name.pdf +++ /dev/null @@ -1 +0,0 @@ -./resources/sjtu-name-blue.pdf \ No newline at end of file diff --git a/sample/pdf/authorization.pdf b/pdf/authorization.pdf similarity index 100% rename from sample/pdf/authorization.pdf rename to pdf/authorization.pdf diff --git a/sample/pdf/originality.pdf b/pdf/originality.pdf similarity index 100% rename from sample/pdf/originality.pdf rename to pdf/originality.pdf diff --git a/sample/figure/sjtu-badge.pdf b/sample/figure/sjtu-badge.pdf deleted file mode 120000 index 9daa5164..00000000 --- a/sample/figure/sjtu-badge.pdf +++ /dev/null @@ -1 +0,0 @@ -../../logos/sjtu-badge.pdf \ No newline at end of file diff --git a/sample/figure/sjtu-name.pdf b/sample/figure/sjtu-name.pdf deleted file mode 120000 index 794d00d8..00000000 --- a/sample/figure/sjtu-name.pdf +++ /dev/null @@ -1 +0,0 @@ -../../logos/sjtu-name.pdf \ No newline at end of file diff --git a/scripts/pack.sh b/scripts/pack.sh deleted file mode 100755 index 5983b487..00000000 --- a/scripts/pack.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash - -# This script is used for creating CTAN archive of sjtuthesis. - -if [ "$#" -ne 5 ]; then - echo "Usage: $0 SOURCE_DIR LOGO_DIR SAMPLE_DIR RELEASE_DIR VERSION" >&2 - exit 1 -fi - -JOB_NAME=sjtuthesis -WORKING_DIR=$PWD -VERSION=$5 - -TEMP_DIR=/tmp/$JOB_NAME - -SOURCE_DIR=$WORKING_DIR/$1 -LOGO_DIR=$WORKING_DIR/$2 -SAMPLE_DIR=$WORKING_DIR/$3 -RELEASE_DIR=$WORKING_DIR/$4 -OUTPUT_DIR=$RELEASE_DIR/$JOB_NAME-$VERSION - -TDS_DIR=$TEMP_DIR/TDS -CTAN_DIR=$TEMP_DIR/$JOB_NAME - -SRC_DIR=$TDS_DIR/source/latex/$JOB_NAME -TEX_DIR=$TDS_DIR/tex/latex/$JOB_NAME -DOC_DIR=$TDS_DIR/doc/latex/$JOB_NAME - -mkdir -p $TEMP_DIR -mkdir -p $TDS_DIR -mkdir -p $CTAN_DIR - -if [ -d $RELEASE_DIR ]; then - echo "Directory ${4} already exists" - exit 1 -else - mkdir -p $RELEASE_DIR -fi - -cp -r $SAMPLE_DIR $OUTPUT_DIR - -mkdir -p $SRC_DIR -mkdir -p $TEX_DIR -mkdir -p $DOC_DIR - -cp $SOURCE_DIR/$JOB_NAME.dtx $TEMP_DIR/ -cp $SOURCE_DIR/latexmkrc.pl $TEMP_DIR/latexmkrc -cp $SAMPLE_DIR/thesis.tex $TEMP_DIR/ -cp $LOGO_DIR/sjtu-badge.pdf $TEMP_DIR/ -cp $LOGO_DIR/sjtu-logo.pdf $TEMP_DIR/ -cp $LOGO_DIR/sjtu-name.pdf $TEMP_DIR/ - -cd $TEMP_DIR -xetex --interaction=batchmode $JOB_NAME.dtx >/dev/null -latexmk -silent $JOB_NAME.dtx >/dev/null -latexmk -silent -c $JOB_NAME.dtx >/dev/null -latexmk -silent -cd -C $OUTPUT_DIR/thesis.tex >/dev/null - -# All files should be rw-r--r-- -chmod 644 $TEMP_DIR/*.* - -cp $TEMP_DIR/*.dtx $SRC_DIR/ -cp $TEMP_DIR/*.ins $SRC_DIR/ -cp $TEMP_DIR/sjtudoc.cls $SRC_DIR/ - -cp $TEMP_DIR/$JOB_NAME.cls $TEX_DIR/ -cp $TEMP_DIR/*.ltx $TEX_DIR/ - -# These files should not be put in doc/ -cp $TEMP_DIR/sjtu-badge.pdf $TEX_DIR/ -cp $TEMP_DIR/sjtu-logo.pdf $TEX_DIR/ -cp $TEMP_DIR/sjtu-name.pdf $TEX_DIR/ - -cp $TEMP_DIR/$JOB_NAME.pdf $DOC_DIR/ -cp $TEMP_DIR/$JOB_NAME.pdf $RELEASE_DIR/ - -# Overleaf -cp $TEX_DIR/*.* $OUTPUT_DIR/ -cp $(kpsewhich gb7714-2015.bbx) $OUTPUT_DIR/ -cp $(kpsewhich gb7714-2015.cbx) $OUTPUT_DIR/ - -# Make Overleaf zip -cd $RELEASE_DIR -zip -q -r -9 $JOB_NAME-overleaf-v$VERSION.zip $JOB_NAME-$VERSION - -rm $OUTPUT_DIR/gb7714-2015.* -cp $SOURCE_DIR/latexmkrc.pl $OUTPUT_DIR/latexmkrc -cp $SOURCE_DIR/sample.mk $OUTPUT_DIR/Makefile -cp $SOURCE_DIR/sample.bat $OUTPUT_DIR/compile.bat - -zip -q -r -9 $JOB_NAME-v$VERSION.zip $JOB_NAME-$VERSION - -# Make TDS zip -cd $TDS_DIR -zip -q -r -9 $JOB_NAME.tds.zip . - -cp $TEMP_DIR/*.dtx $CTAN_DIR/ -cp $TEMP_DIR/*.ins $CTAN_DIR/ -cp $TEMP_DIR/*.pdf $CTAN_DIR/ - -rm $TEMP_DIR/*.* -cp $TDS_DIR/*.zip $TEMP_DIR/ -rm -r $TDS_DIR - -# Make CTAN zip -cd $TEMP_DIR -rm $TEMP_DIR/latexmkrc -zip -q -r -9 $JOB_NAME.zip . - -cd $WORKING_DIR -cp -f $TEMP_DIR/*.zip $RELEASE_DIR/ - -rm -r $TEMP_DIR -rm -r $OUTPUT_DIR diff --git a/scripts/unpack.sh b/scripts/unpack.sh deleted file mode 100755 index 73b030c7..00000000 --- a/scripts/unpack.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -cd logos - -cp sjtu-badge.pdf ../sample -cp sjtu-logo.pdf ../sample -cp sjtu-name.pdf ../sample - -cd - - -cd source - -xetex -interaction=batchmode sjtuthesis.dtx -cp sjtuthesis.cls ../sample -cp sjtuthesis-bachelor.ltx ../sample -cp sjtuthesis-graduate.ltx ../sample - -cd - diff --git a/logos/resources/sjtu-badge-blue.pdf b/sjtu-badge.pdf similarity index 100% rename from logos/resources/sjtu-badge-blue.pdf rename to sjtu-badge.pdf diff --git a/logos/resources/sjtu-logo-black.pdf b/sjtu-logo.pdf similarity index 100% rename from logos/resources/sjtu-logo-black.pdf rename to sjtu-logo.pdf diff --git a/logos/resources/sjtu-name-blue.pdf b/sjtu-name.pdf similarity index 100% rename from logos/resources/sjtu-name-blue.pdf rename to sjtu-name.pdf diff --git a/sjtuthesis-bachelor.ltx b/sjtuthesis-bachelor.ltx new file mode 100644 index 00000000..eaa0e8f8 --- /dev/null +++ b/sjtuthesis-bachelor.ltx @@ -0,0 +1,233 @@ +%% +%% This is file `sjtuthesis-bachelor.ltx', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% sjtuthesis.dtx (with options: `bachelor') +%% +%% Copyright (C) 2009-2017 by weijianwen +%% (C) 2018-2019 by SJTUG +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This file has the LPPL maintenance status "maintained". +%% +%% The Current Maintainer of this work is Alexara Wu. +%% +\ProvidesFile{sjtuthesis-bachelor.ltx} + [2019/06/16 1.0.0rc Shanghai Jiao Tong University Thesis Template] +\ifsjtu@degree@course + \sjtu@def@label{degreetypeChi}{} + \sjtu@def@label{degreetypeEng}{} +\else + \sjtu@def@label{degreetypeChi}{学士} + \sjtu@def@label{degreetypeEng}{Bachelor} +\fi +\sjtu@def@label{authorChi}{学生姓名} +\sjtu@def@label{studentidChi}{学生学号} +\sjtu@def@label{supervisorChi}{指导教师} +\sjtu@def@label{coursenameChi}{课程名称} +\sjtu@def@label{majorChi}{专业} +\sjtu@def@label{departmentChi}{学院(系)} +\ifsjtu@degree@course + \sjtu@def@label{thesiscat}{课程论文} + \def\sjtu@label@thesistype{\sjtu@label@thesiscat} + \sjtu@def@label{subjectChi}{\sjtu@label@thesiscat} + \sjtu@def@label{subjectEng}{Course Paper} +\else + \sjtu@def@label{thesiscat}{学位论文} + \def\sjtu@label@thesistype{毕业设计(论文)} + \sjtu@def@label{subjectChi}{\sjtu@label@degreetypeChi\sjtu@label@thesiscat} + \sjtu@def@label{subjectEng}{Thesis of \sjtu@label@degreetypeEng} +\fi +\sjtu@def@label{bigabstract}{英文大摘要} +\geometry{% + paper = a4paper, + vmargin = {84bp, 72bp}, + hmargin = 90bp, + headheight = 60bp, + headsep = 12bp, +} +\ifsjtu@language@english + \def\sjtu@titlemark{\sjtu@value@entitle} + \newcommand{\sjtu@fancyhead}{% + \parbox[b]{0.75\textwidth}{% + \raggedleft\nouppercase{\footnotesize\heiti\sjtu@titlemark}}} + \newcommand{\sjtu@fancyfoot}[2]{% + \small --~~Page~~{\bfseries{#1}}~~of~~{\bfseries{#2}}~~--} +\else + \def\sjtu@titlemark{\sjtu@value@title} + \newcommand{\sjtu@fancyhead}{% + \parbox[b]{0.75\textwidth}{% + \raggedleft\nouppercase{\small\heiti\sjtu@titlemark}}} + \newcommand{\sjtu@fancyfoot}[2]{% + \small 第~{\bfseries{#1}}~页\,共~{\bfseries{#2}}~页} +\fi +\fancypagestyle{sjtu@front}{% + \fancyhf{} + \fancyhead[L]{\includegraphics{sjtu-logo.pdf}} + \fancyhead[R]{\sjtu@fancyhead} + \fancyfoot[C]{\sjtu@fancyfoot{\thepage}{\lastpageref{pagesLTS.Roman}}} +} +\fancypagestyle{sjtu@plain}{% + \fancyhf{} + \fancyhead[L]{\includegraphics{sjtu-logo.pdf}} + \fancyhead[R]{\sjtu@fancyhead} + \fancyfoot[C]{\sjtu@fancyfoot{\thepage}{\lastpageref{pagesLTS.arabic}}} +} +\fancypagestyle{sjtu@biglast}{% + \fancyhf{} + \fancyhead[L]{\includegraphics{sjtu-logo.pdf}} + \fancyhead[R]{\sjtu@fancyhead} + \fancyfoot[C]{\sjtu@fancyfoot{\theCurrentPageLocal}% + {\lastpageref{pagesLTS.roman.local}}} +} +\renewcommand{\frontmatter}{% + \cleardoublepage + \@mainmatterfalse + \pagenumbering{Roman} + \pagestyle{sjtu@front} +} +\renewcommand{\mainmatter}{% + \cleardoublepage + \@mainmattertrue + \sjtu@setfloatfonttrue + \pagenumbering{arabic} + \pagestyle{sjtu@plain} +} +\renewcommand{\backmatter}{% + \cleardoublepage + \@mainmatterfalse +} +\ctexset{% + subsection/format = \zihao{-4}\normalfont, +} +\renewcommand{\cftchapfont}{\normalfont} +\renewcommand{\cftchapleader}{\normalfont\cftdotfill{\cftdotsep}} +\renewcommand{\cftchappagefont}{\normalfont} +\NewDocumentEnvironment{abstract}{}{% + \cleardoublepage + \pdfbookmark[0]{\sjtu@label@abstract}{abstract} + \chapter*{% + \sjtu@value@title \vskip 2ex + \begingroup + \zihao{4} + \sjtu@label@abstractChi + \endgroup + } + \@mkboth{\sjtu@label@abstractChi}% + {\sjtu@label@abstractChi}% +}{% + \vskip 3ex \noindent + \begingroup + \zihao{-4} + \heiti\sjtu@label@keywordsChi + \endgroup + \begingroup + \zihao{5} + \sjtu@value@keywords + \endgroup +} +\NewDocumentEnvironment{enabstract}{}{% + \cleardoublepage + \chapter*{% + \MakeUppercase\sjtu@value@entitle \vskip 2ex + \begingroup + \zihao{4} + \MakeUppercase\sjtu@label@abstractEng + \endgroup + } + \@mkboth{\sjtu@label@abstractEng}% + {\sjtu@label@abstractEng}% +}{% + \vskip 3ex \noindent + \begingroup + \zihao{-4}\bfseries + \sjtu@label@keywordsEng + \endgroup + \begingroup + \zihao{5} + \sjtu@value@enkeywords + \endgroup +} +\newcommand{\sjtu@bigabstract}[1]{\long\gdef\sjtu@bigabstract@body{#1}} +\NewDocumentEnvironment{bigabstract}{}{% + \Collect@Body\sjtu@bigabstract +}{% + \ifsjtu@degree@course\relax\else + \ifsjtu@language@english\relax\else + \AtEndDocument{% + \cleardoublepage + \pagenumbering{roman} + \pagestyle{sjtu@biglast} + \pdfbookmark[0]{\sjtu@label@bigabstract}{bigabstract}% + \chapter*{\MakeUppercase\sjtu@value@entitle} + \@mkboth{\sjtu@label@bigabstract}% + {\sjtu@label@bigabstract}% + \sjtu@bigabstract@body + } + \fi + \fi +} +\RenewDocumentCommand\maketitle{}{% + \pdfbookmark[0]{\sjtu@label@titlepage}{titlepage} + \sjtu@makechinesetitle% +} +\newcommand{\sjtu@makechinesetitle}{% + \cleardoublepage + \thispagestyle{empty} + \begin{center} + \kaishu + \vspace*{48bp} + \includegraphics{sjtu-name.pdf} + \vskip 28bp + {\fontsize{32}{32}\sjtu@label@subjectChi} + \vskip 16bp + {\zihao{-2}\MakeUppercase\sjtu@label@subjectEng} + \vskip 16bp + \includegraphics{sjtu-badge.pdf} + \vskip \stretch{2} + \begingroup + \zihao{2} + \begin{tabular}{r@{:}l} + 论文题目 & + \begin{minipage}[t]{280pt} + \zihao{-2} + \begin{center} + \sjtu@uline\sjtu@value@title + \end{center} + \end{minipage} + \end{tabular} + \endgroup + \vskip \stretch{1} + \begingroup + \zihao{3} + \def\arraystretch{1.1} + \begin{tabular} + {>{\begin{CJKfilltwosides}{4\ccwd}}r<{\end{CJKfilltwosides}}@{:}c} + \sjtu@label@authorChi & \sjtu@value@author \\ \cline{2-2} + \sjtu@label@studentidChi & \makebox[180pt]{\sjtu@value@studentid} \\ + \cline{2-2} + \ifsjtu@degree@course + \sjtu@label@coursenameChi & \sjtu@value@coursename \\ \cline{2-2} + \else + \sjtu@label@majorChi & \sjtu@value@major \\ \cline{2-2} + \fi + \sjtu@label@supervisorChi & \sjtu@value@supervisor \\ \cline{2-2} + \sjtu@label@departmentChi & \sjtu@value@department \\ \cline{2-2} + \end{tabular} + \endgroup + \vskip 40bp + \end{center} + \cleardoublepage +} +\endinput +%% +%% End of file `sjtuthesis-bachelor.ltx'. diff --git a/sjtuthesis-graduate.ltx b/sjtuthesis-graduate.ltx new file mode 100644 index 00000000..77174eb5 --- /dev/null +++ b/sjtuthesis-graduate.ltx @@ -0,0 +1,240 @@ +%% +%% This is file `sjtuthesis-graduate.ltx', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% sjtuthesis.dtx (with options: `graduate') +%% +%% Copyright (C) 2009-2017 by weijianwen +%% (C) 2018-2019 by SJTUG +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This file has the LPPL maintenance status "maintained". +%% +%% The Current Maintainer of this work is Alexara Wu. +%% +\ProvidesFile{sjtuthesis-graduate.ltx} + [2019/06/16 1.0.0rc Shanghai Jiao Tong University Thesis Template] +\ifsjtu@degree@doctor + \sjtu@def@label{degreetypeChi}{博士} + \sjtu@def@label{degreetypeEng}{Doctor} +\else + \sjtu@def@label{degreetypeChi}{硕士} + \sjtu@def@label{degreetypeEng}{Master} +\fi +\sjtu@def@label{authorChi}{\sjtu@label@degreetypeChi 研究生} +\sjtu@def@label{authorEng}{Candidate} +\sjtu@def@label{studentidChi}{学号} +\sjtu@def@label{studentidEng}{Student ID} +\sjtu@def@label{supervisorChi}{导师} +\sjtu@def@label{supervisorEng}{Supervisor} +\sjtu@def@label{assisupervisorChi}{副导师} +\sjtu@def@label{assisupervisorEng}{Assistant Supervisor} +\sjtu@def@label{degreeChi}{申请学位} +\sjtu@def@label{degreeEng}{Academic Degree Applied for} +\sjtu@def@label{majorChi}{学科} +\sjtu@def@label{majorEng}{Speciality} +\sjtu@def@label{departmentChi}{所在单位} +\sjtu@def@label{departmentEng}{Affiliation} +\sjtu@def@label{defenddateChi}{答辩日期} +\sjtu@def@label{defenddateEng}{Date of Defence} +\sjtu@def@label{conferringChi}{授予学位单位} +\sjtu@def@label{conferringEng}{Degree-Conferring-Institution} +\sjtu@def@label{fundChi}{资助基金} +\sjtu@def@label{fundEng}{Funded by} +\sjtu@def@label{thesiscat}{学位论文} +\def\sjtu@label@thesistype{\sjtu@label@thesiscat} +\sjtu@def@label{subjectChi}{% + \sjtu@label@schoolChi\sjtu@label@degreetypeChi\sjtu@label@thesiscat +} +\sjtu@def@label{subjectEng}{% + Dissertation Submitted to \sjtu@label@schoolEng \\% + for the Degree of \sjtu@label@degreetypeEng +} +\geometry{% + paper = a4paper, + top = 3.5cm, + bottom = 4.0cm, + left = 3.3cm, + right = 2.8cm, + headheight = 1.0cm, + headsep = 0.5cm, +} +\newcommand{\sjtu@fancyfoot}[2]{ + \ifsjtu@review\relax\else + \ifx#2\@empty\else + \zihao{-5}{\bfseries #1}\\{#2} + \fi + \fi +} +\fancypagestyle{sjtu@title}{% + \fancyhf{} + \fancyfoot[C]{\sjtu@fancyfoot{\sjtu@label@fundChi}{\sjtu@value@fund}} + \renewcommand{\headrulewidth}{0pt} + \renewcommand{\footrulewidth}{0pt} +} +\fancypagestyle{sjtu@entitle}{% + \fancyhf{} + \fancyfoot[C]{\sjtu@fancyfoot{\sjtu@label@fundEng}{\sjtu@value@enfund}} + \renewcommand{\headrulewidth}{0pt} + \renewcommand{\footrulewidth}{0pt} +} +\fancypagestyle{sjtu@plain}{% + \fancyhf{} + \fancyhead[C]{\zihao{-5}\sjtu@label@subjectChi} + \fancyfoot[C]{\small ---~{\bfseries\thepage}~---} + \renewcommand{\headrule}{% + \hrule\@height2.25\p@\@width\headwidth + \vskip 0.75\p@ + \hrule\@height0.75\p@\@width\headwidth + \vskip -2.75\p@ + } +} +\renewcommand{\frontmatter}{% + \cleardoublepage + \@mainmatterfalse + \pagenumbering{Roman} + \pagestyle{sjtu@plain} +} +\renewcommand{\mainmatter}{% + \cleardoublepage + \@mainmattertrue + \sjtu@setfloatfonttrue + \pagenumbering{arabic} + \pagestyle{sjtu@plain} +} +\renewcommand{\backmatter}{% + \cleardoublepage + \@mainmatterfalse +} +\renewcommand{\cftchapfont}{\bfseries\heiti} +\renewcommand{\cftchapleader}{\normalfont\cftdotfill{\cftdotsep}} +\NewDocumentEnvironment{abstract}{}{% + \cleardoublepage + \pdfbookmark[0]{\sjtu@label@abstract}{abstract} + \chapter*{% + \sjtu@value@title \vskip 2ex + \begingroup + \sjtu@label@abstractChi + \endgroup + } + \@mkboth{\sjtu@label@abstractChi}% + {\sjtu@label@abstractChi}% + \zihao{4} +}{% + \vskip 3ex \noindent + \begingroup + \heiti\sjtu@label@keywordsChi + \endgroup + \begingroup + \sjtu@value@keywords + \endgroup +} +\NewDocumentEnvironment{enabstract}{}{% + \cleardoublepage + \chapter*{% + \MakeUppercase\sjtu@value@entitle \vskip 2ex + \begingroup + \MakeUppercase\sjtu@label@abstractEng + \endgroup + } + \@mkboth{\sjtu@label@abstractEng}% + {\sjtu@label@abstractEng}% + \zihao{4} +}{% + \vskip 3ex \noindent + \begingroup + \bfseries\MakeUppercase + \sjtu@label@keywordsEng + \endgroup + \begingroup + \sjtu@value@enkeywords + \endgroup +} +\newcommand{\sjtu@bigabstract}[1]{\long\gdef\sjtu@bigabstract@body{#1}} +\NewDocumentEnvironment{bigabstract}{}{% + \Collect@Body\sjtu@bigabstract +}{% + \relax +} +\RenewDocumentCommand\maketitle{}{% + \pdfbookmark[0]{\sjtu@label@titlepage}{titlepage} + \sjtu@makechinesetitle% + \sjtu@makeenglishtitle% +} +\newcommand{\sjtu@makechinesetitle}{% + \cleardoublepage + \thispagestyle{sjtu@title} + \begin{center} + \vspace*{40bp} + {\zihao{-2}\sjtu@label@subjectChi} + \vskip \stretch{4} + {\zihao{2}\heiti\sjtu@value@title \vskip 1bp} + \vskip \stretch{5} + \begingroup + \zihao{4} + \def\tabcolsep{1bp} + \def\arraystretch{1.25} + \begin{tabular} + {>{\begin{CJKfilltwosides}[t]{6.5\ccwd}\heiti}r<{\end{CJKfilltwosides}} + @{:}l} + \sjtu@label@authorChi & \sjtu@value@author \\ + \sjtu@label@studentidChi & \sjtu@value@studentid \\ + \sjtu@label@supervisorChi & \sjtu@value@supervisor \\ + \ifx\sjtu@value@assisupervisor\@empty\else + \sjtu@label@assisupervisorChi & \sjtu@value@assisupervisor \\ + \fi + \sjtu@label@degreeChi & \sjtu@value@degree \\ + \sjtu@label@majorChi & \sjtu@value@major \\ + \sjtu@label@departmentChi & \sjtu@value@department \\ + \sjtu@label@defenddateChi & \sjtu@value@date \\ + \sjtu@label@conferringChi & \sjtu@label@schoolChi \\ + \end{tabular} + \endgroup + \vskip 26bp + \end{center} + \cleardoublepage +} +\newcommand{\sjtu@makeenglishtitle}{% + \cleardoublepage + \thispagestyle{sjtu@entitle} + \begin{center} + \vspace*{28bp} + {\zihao{-2}\sjtu@label@subjectEng \vskip 1bp} + \vskip \stretch{4} + {\zihao{2}\bfseries\MakeUppercase\sjtu@value@entitle \vskip 1bp} + \vskip \stretch{5} + \begingroup + \zihao{4} + \def\tabcolsep{1bp} + \def\arraystretch{1.3} + \begin{tabular} + {>{\bfseries}l<{:~}p{.45\textwidth}} + \sjtu@label@authorEng & \sjtu@value@enauthor \\ + \sjtu@label@studentidEng & \sjtu@value@studentid \\ + \sjtu@label@supervisorEng & \sjtu@value@ensupervisor \\ + \ifx\sjtu@value@enassisupervisor\@empty\else + \sjtu@label@assisupervisorEng & \sjtu@value@enassisupervisor \\ + \fi + \sjtu@label@degreeEng & \sjtu@value@endegree \\ + \sjtu@label@majorEng & \sjtu@value@enmajor \\ + \sjtu@label@departmentEng & \sjtu@value@endepartment \\ + \sjtu@label@defenddateEng & \sjtu@value@endate \\ + \sjtu@label@conferringEng & \sjtu@label@schoolEng \\ + \end{tabular} + \endgroup + \vskip 26bp + \end{center} + \cleardoublepage +} +\endinput +%% +%% End of file `sjtuthesis-graduate.ltx'. diff --git a/sjtuthesis.cls b/sjtuthesis.cls new file mode 100644 index 00000000..66f5d02e --- /dev/null +++ b/sjtuthesis.cls @@ -0,0 +1,925 @@ +%% +%% This is file `sjtuthesis.cls', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% sjtuthesis.dtx (with options: `class') +%% +%% Copyright (C) 2009-2017 by weijianwen +%% (C) 2018-2019 by SJTUG +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This file has the LPPL maintenance status "maintained". +%% +%% The Current Maintainer of this work is Alexara Wu. +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{sjtuthesis} + [2019/06/16 1.0.0rc Shanghai Jiao Tong University Thesis Template] +\hyphenation{SJTU-Thesis} +\def\sjtuthesis{SJTU\textsc{Thesis}} +\def\version{1.0.0rc} +\RequirePackage{kvoptions} +\SetupKeyvalOptions{ + family=sjtu, + prefix=sjtu@, + setkeys=\kvsetkeys} +\DeclareStringOption[doctor]{degree}[doctor] +\DeclareStringOption[chinese]{language}[chinese] +\DeclareStringOption[5]{zihao}[5] +\DeclareStringOption[all]{setlatinfont}[all] +\DeclareStringOption[GB]{mathstyle}[GB] +\DeclareStringOption[gb7714-2015]{bibstyle}[gb7714-2015] +\DeclareBoolOption{review} +\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}} +\ProcessKeyvalOptions* +\newcommand{\sjtu@validate@key}[1]{% + \@ifundefined{sjtu@#1@\csname sjtu@#1\endcsname true}{% + \ClassError{sjtuthesis}{Invalid value '\csname sjtu@#1\endcsname'}{}% + }{% + \csname sjtu@#1@\csname sjtu@#1\endcsname true\endcsname + }% +} +\newif\ifsjtu@degree@course +\newif\ifsjtu@degree@bachelor +\newif\ifsjtu@degree@master +\newif\ifsjtu@degree@doctor +\sjtu@validate@key{degree} +\ifsjtu@degree@course\sjtu@degree@bachelortrue\fi +\ifsjtu@degree@doctor\sjtu@degree@mastertrue\fi +\newif\ifsjtu@language@chinese +\newif\ifsjtu@language@english +\sjtu@validate@key{language} +\newif\ifsjtu@setlatinfont@none +\newif\ifsjtu@setlatinfont@main +\newif\ifsjtu@setlatinfont@math +\newif\ifsjtu@setlatinfont@all +\sjtu@validate@key{setlatinfont} +\ifsjtu@setlatinfont@all + \sjtu@setlatinfont@maintrue + \sjtu@setlatinfont@mathtrue +\fi +\newif\ifsjtu@mathstyle@GB +\@ifundefined{sjtu@mathstyle@\csname sjtu@mathstyle\endcsname true}{}{% + \sjtu@mathstyle@GBtrue + \def\sjtu@mathstyle{ISO} +} +\ifsjtu@language@english + \PassOptionsToClass{scheme=plain}{ctexbook} +\fi +\PassOptionsToPackage{no-math}{fontspec} +\PassOptionsToPackage{math-style=\sjtu@mathstyle}{unicode-math} +\LoadClass[a4paper,zihao=\sjtu@zihao,linespread=1.3,UTF8]{ctexbook} +\ifsjtu@degree@bachelor + \AtEndOfClass{\input{sjtuthesis-bachelor.ltx}} +\else + \ifsjtu@degree@master + \AtEndOfClass{\input{sjtuthesis-graduate.ltx}} + \fi +\fi +\RequirePackage{etoolbox} +\RequirePackage{xparse} +\RequirePackage{environ} +\RequirePackage{geometry} +\RequirePackage{fancyhdr} +\RequirePackage{pageslts} +\RequirePackage{amsmath} +\ifsjtu@setlatinfont@math + \RequirePackage{unicode-math} +\fi +\RequirePackage{anyfontsize} +\RequirePackage{xcolor} +\RequirePackage{graphicx} +\RequirePackage{array} +\RequirePackage{booktabs} +\RequirePackage{longtable} +\RequirePackage{caption} +\RequirePackage[list=off]{bicaption} +\RequirePackage{subcaption} +\RequirePackage[backend=biber,style=\sjtu@bibstyle]{biblatex} +\RequirePackage[titles]{tocloft} +\RequirePackage[inline]{enumitem} +\RequirePackage[perpage, bottom]{footmisc} +\RequirePackage{pdfpages} +\includepdfset{fitpaper=true} +\RequirePackage{hyperref} +\newcommand{\sjtu@def@term}[1]{% + \expandafter\gdef\csname #1\endcsname##1{% + \expandafter\gdef\csname sjtu@value@#1\endcsname{##1}} + \csname #1\endcsname{} + \define@key{sjtuvalue}{#1}{\csname #1\endcsname{##1}}} +\sjtu@def@term{title} +\sjtu@def@term{entitle} +\sjtu@def@term{keywords} +\sjtu@def@term{enkeywords} +\sjtu@def@term{author} +\sjtu@def@term{supervisor} +\sjtu@def@term{assisupervisor} +\sjtu@def@term{enauthor} +\sjtu@def@term{ensupervisor} +\sjtu@def@term{enassisupervisor} +\sjtu@def@term{studentid} +\sjtu@def@term{degree} +\sjtu@def@term{endegree} +\sjtu@def@term{department} +\sjtu@def@term{endepartment} +\sjtu@def@term{major} +\sjtu@def@term{enmajor} +\sjtu@def@term{coursename} +\sjtu@def@term{encoursename} +\sjtu@def@term{fund} +\sjtu@def@term{enfund} +\sjtu@def@term{date} +\sjtu@def@term{endate} +\NewDocumentCommand\sjtuSetInfo{}{\setkeys{sjtuvalue}} +\newcommand{\sjtu@def@label}[2]{% + \expandafter\gdef\csname sjtu@label@#1\endcsname{#2} + \define@key{sjtulabel}{#1}{% + \expandafter\gdef\csname sjtu@label@#1\endcsname{##1}}} +\sjtu@def@label{schoolChi}{上海交通大学} +\sjtu@def@label{schoolEng}{Shanghai Jiao Tong University} +\sjtu@def@label{originalityChi}{原创性声明} +\sjtu@def@label{originalityEng}{Declaration of Originality} +\sjtu@def@label{authorizationChi}{版权使用授权书} +\sjtu@def@label{authorizationEng}{Declaration of Authorization} +\sjtu@def@label{origtitle}{\sjtu@label@thesistype\sjtu@label@originalityChi} +\sjtu@def@label{authtitle}{\sjtu@label@thesistype\sjtu@label@authorizationChi} +\sjtu@def@label{origbody}{% + 本人郑重声明:所呈交的\sjtu@label@thesistype ,是本人在导师的指导下, + 独立进行研究工作所取得的成果。除文中已经注明引用的内容外,本论文不包含 + 任何其他个人或集体已经发表或撰写过的作品成果。对本文的研究做出重要贡献 + 的个人和集体,均已在文中以明确方式标明。本人完全意识到本声明的法律结果 + 由本人承担。} +\sjtu@def@label{authbody}{% + 本\sjtu@label@thesistype 作者 + 完全了解学校有关保留、使用\sjtu@label@thesistype 的规定,同意学校保留 + 并向国家有关部门或机构送交论文的复印件和电子版,允许论文被查阅和借阅。 + 本人授权\sjtu@label@schoolChi 可以将本\sjtu@label@thesistype 的全部或 + 部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描等复制手段保存 + 和汇编本\sjtu@label@thesistype 。} +\sjtu@def@label{abstractChi}{摘\quad 要} +\sjtu@def@label{abstractEng}{Abstract} +\sjtu@def@label{keywordsChi}{关键词:} +\sjtu@def@label{keywordsEng}{Key words:~} +\ifsjtu@language@english + \sjtu@def@label{titlepage}{Title Page} + \def\sjtu@label@originality{\sjtu@label@originalityEng} + \def\sjtu@label@authorization{\sjtu@label@authorizationEng} + \def\sjtu@label@abstract{\sjtu@label@abstractEng} + \sjtu@def@label{contents}{Contents} + \sjtu@def@label{figure}{Figure} + \sjtu@def@label{listfigure}{List of Figures} + \sjtu@def@label{table}{Table} + \sjtu@def@label{listtable}{List of Tables} + \sjtu@def@label{algorithm}{Algorithm} + \sjtu@def@label{listalgorithm}{List of Algorithms} + \sjtu@def@label{nomenclature}{Nomenclature} + \sjtu@def@label{summary}{Summary} + \sjtu@def@label{acknowledgements}{Acknowledgements} + \sjtu@def@label{publications}{Publications} + \sjtu@def@label{patents}{Patents} + \sjtu@def@label{projects}{Projects} + \sjtu@def@label{resume}{Resume} +\else + \sjtu@def@label{titlepage}{扉页} + \def\sjtu@label@originality{\sjtu@label@originalityChi} + \def\sjtu@label@authorization{\sjtu@label@authorizationChi} + \def\sjtu@label@abstract{\sjtu@label@abstractChi} + \sjtu@def@label{contents}{目\quad 录} + \sjtu@def@label{figure}{图} + \sjtu@def@label{listfigure}{插图索引} + \sjtu@def@label{table}{表} + \sjtu@def@label{listtable}{表格索引} + \sjtu@def@label{algorithm}{算法} + \sjtu@def@label{listalgorithm}{算法索引} + \sjtu@def@label{nomenclature}{主要符号对照表} + \sjtu@def@label{summary}{全文总结} + \sjtu@def@label{acknowledgements}{致\quad 谢} + \sjtu@def@label{publications}% + {攻读\sjtu@label@degreetypeChi 学位期间已发表或录用的论文} + \sjtu@def@label{patents}% + {攻读\sjtu@label@degreetypeChi 学位期间申请的专利} + \sjtu@def@label{projects}% + {攻读\sjtu@label@degreetypeChi 学位期间参与的项目} + \sjtu@def@label{resume}{简\quad 历} +\fi +\NewDocumentCommand\sjtuSetLabel{}{\setkeys{sjtulabel}} +\ctexset{% + contentsname = \sjtu@label@contents, + listfigurename = \sjtu@label@listfigure, + listtablename = \sjtu@label@listtable} +\newif\ifsjtu@xitsnew +\@ifpackagelater{fontspec}{2017/01/20}{ + \IfFontExistsTF{XITSMath-Regular.otf}{ + \sjtu@xitsnewtrue + }{} +}{} +\ifsjtu@setlatinfont@main + \ifsjtu@xitsnew + \setmainfont{XITS}[ + Extension = .otf, + UprightFont = *-Regular, + BoldFont = *-Bold, + ItalicFont = *-Italic, + BoldItalicFont = *-BoldItalic, + UprightFeatures = { SmallCapsFont = texgyretermes-regular }, + BoldFeatures = { SmallCapsFont = texgyretermes-bold }, + ItalicFeatures = { SmallCapsFont = texgyretermes-italic }, + BoldItalicFeatures = { SmallCapsFont = texgyretermes-bolditalic }, + SmallCapsFeatures = { Letters = SmallCaps } + ] + \else + \setmainfont{xits}[ + Extension = .otf, + UprightFont = *-regular, + BoldFont = *-bold, + ItalicFont = *-italic, + BoldItalicFont = *-bolditalic, + UprightFeatures = { SmallCapsFont = texgyretermes-regular }, + BoldFeatures = { SmallCapsFont = texgyretermes-bold }, + ItalicFeatures = { SmallCapsFont = texgyretermes-italic }, + BoldItalicFeatures = { SmallCapsFont = texgyretermes-bolditalic }, + SmallCapsFeatures = { Letters = SmallCaps } + ] + \fi + \RequirePackage[opentype,scaled=.9]{sourcesanspro} + \RequirePackage[opentype,scaled=.9]{sourcecodepro} +\fi +\ifsjtu@setlatinfont@math + \ifsjtu@xitsnew + \setmathfont{XITSMath-Regular}[ + Extension = .otf, + BoldFont = XITSMath-Bold, + StylisticSet = 8 + ] + \setmathfont{XITSMath-Regular.otf}[range={cal,bfcal},StylisticSet=1] + \else + \setmathfont{xits-math}[ + Extension = .otf, + BoldFont = *bold, + StylisticSet = 8 + ] + \setmathfont{xits-math.otf}[range={cal,bfcal},StylisticSet=1] + \fi +\fi +\patchcmd\cleardoublepage% + {\newpage}{\thispagestyle{empty}\newpage} + {}{} +\patchcmd\chapter% + {\thispagestyle{\CTEX@chapter@pagestyle}}{} + {}{} +\AtBeginDocument{% + \pagenumbering{Alph} + \pagestyle{empty}} +\ctexset{% + chapter={% + format = \zihao{3}\bfseries\heiti\centering, + nameformat = {}, + titleformat = {}, + aftername = \quad, + afterindent = true, + beforeskip = 1ex, + afterskip = 2ex + }, + section={% + format = \zihao{4}\bfseries\heiti, + afterindent = true, + afterskip = 1ex \@plus .2ex + }, + subsection={% + format = \zihao{-4}\bfseries\heiti, + afterindent = true, + afterskip = 1ex \@plus .2ex + }, + subsubsection={% + format = \zihao{-4}\normalfont, + afterindent = true, + afterskip = 1ex \@plus .2ex + }, + paragraph/afterindent = true, + subparagraph/afterindent = true} +\ctexset{% + punct = quanjiao, + space = auto, + autoindent = true} +\AtEndOfClass{\sloppy} +\setlist{nosep} +\setlist*{leftmargin=*} +\setlist[1]{labelindent=\parindent} +\setcounter{secnumdepth}{3} +\setcounter{tocdepth}{2} +\renewcommand{\tableofcontents}{% + \cleardoublepage% + \pdfbookmark[0]{\contentsname}{toc}% + \chapter*{\contentsname}% + \@mkboth{\contentsname}{\contentsname}% + \@starttoc{toc} +} +\renewcommand{\listoffigures}{% + \cleardoublepage% + \pdfbookmark[0]{\listfigurename}{lof}% + \chapter*{\listfigurename}% + \@mkboth{\listfigurename}{\listfigurename}% + \@starttoc{lof} +} +\renewcommand{\listoftables}{% + \cleardoublepage% + \pdfbookmark[0]{\listtablename}{lot}% + \chapter*{\listtablename}% + \@mkboth{\listtablename}{\listtablename}% + \@starttoc{lot} +} +\renewcommand{\cftfigpresnum}{\sjtu@label@figure~} +\renewcommand{\cfttabpresnum}{\sjtu@label@table~} +\AtEndPreamble{% + \newlength{\sjtu@cftfignumwidth@tmp} + \settowidth{\sjtu@cftfignumwidth@tmp}{\cftfigpresnum} + \addtolength{\cftfignumwidth}{\sjtu@cftfignumwidth@tmp} + \newlength{\sjtu@cfttabnumwidth@tmp} + \settowidth{\sjtu@cfttabnumwidth@tmp}{\cfttabpresnum} + \addtolength{\cfttabnumwidth}{\sjtu@cfttabnumwidth@tmp} +} +\renewcommand{\textfraction}{0.15} +\renewcommand{\topfraction}{0.85} +\renewcommand{\bottomfraction}{0.65} +\renewcommand{\floatpagefraction}{0.60} +\AtBeginDocument{% + \renewcommand{\theequation}{\thechapter--\arabic{equation}} + \renewcommand{\thefigure}{\thechapter--\arabic{figure}} + \renewcommand{\p@subfigure}{\thefigure} + \renewcommand{\thetable}{\thechapter--\arabic{table}} +} +\newif\ifsjtu@setfloatfont +\renewcommand{\@floatboxreset}{% + \reset@font + \ifsjtu@setfloatfont + \zihao{5} + \else + \normalsize + \fi + \@setminipage +} +\BeforeBeginEnvironment{longtable} + {\begingroup\ifsjtu@setfloatfont\zihao{5}\fi} +\AfterEndEnvironment{longtable} + {\endgroup} +\NewDocumentCommand{\sjtuSetFloatFontOn}{}{\sjtu@setfloatfonttrue} +\NewDocumentCommand{\sjtuSetFloatFontOff}{}{\sjtu@setfloatfontfalse} +\DeclareCaptionFont{sjtucaptionfont}{\zihao{5}\kaishu} +\DeclareCaptionFont{sjtusubcaptionfont}{\zihao{5}\normalfont} +\captionsetup{% + format = plain, + labelformat = simple, + labelsep = space, + justification = centering, + font = sjtucaptionfont +} +\captionsetup[sub]{% + format = hang, + labelformat = brace, + justification = justified, + font = sjtusubcaptionfont +} +\DeclareCaptionOption{bi-first}[]{% + \def\tablename{\sjtu@label@table} + \def\figurename{\sjtu@label@figure}} +\DeclareCaptionOption{bi-second}[]{% + \def\tablename{Table} + \def\figurename{Figure}} +\captionsetup[bi-first]{bi-first} +\captionsetup[bi-second]{bi-second} +\ifsjtu@mathstyle@GB + \let\mathellipsis\cdots + \AtBeginDocument{% + \renewcommand{\Re}{\operatorname{Re}}% + \renewcommand{\Im}{\operatorname{Im}}% + } +\fi +\newcommand\upe{\mathrm{e}} +\newcommand\upi{\mathrm{i}} +\newcommand\upj{\mathrm{j}} +\newcommand\dif{\mathop{}\!\mathrm{d}} +\newcommand{\sjtu@square}{% + \begingroup\CJKfamily+{zhsong}\symbol{"25A1}\endgroup +} +\newcommand{\sjtu@authconf}{% + \par\hspace{7em}% + {\heiti 保\quad 密}~\sjtu@square,在 \uline{\hspace{3em}} + 年解密后适用本授权书。\par + 本\sjtu@label@thesiscat 属于 + \par\hspace{7em}% + {\heiti 不保密}~\sjtu@square。 + \vskip 1ex + (请在以上方框内打“$\checkmark$”) +} +\newcommand{\sjtu@signbox}[1]{% + \parbox{.45\textwidth}{% + #1 签名: \vskip 4em% + 日期: \hspace{\stretch{3}} 年% + \hspace{\stretch{2}} 月 \hspace{\stretch{2}} 日% + } +} +\NewDocumentCommand{\makeDeclareOriginality}{o}{% + \ifsjtu@review\relax\else + \cleardoublepage + \pdfbookmark[0]{\sjtu@label@originality}{origtitle} + \IfNoValueTF{#1}{% + \thispagestyle{empty} + \chapter*{\zihao{-2}\sjtu@label@schoolChi \\% + \sjtu@label@origtitle} + \begingroup + \zihao{4} + \sjtu@label@origbody + \vskip 16ex + \noindent + \begin{minipage}{\textwidth} + \hfill + \sjtu@signbox{\sjtu@label@thesiscat 作者} + \end{minipage} + \endgroup + } + {\includepdf[pagecommand={\thispagestyle{empty}}]{#1}} + \cleardoublepage + \fi +} +\NewDocumentCommand{\makeDeclareAuthorization}{o}{% + \ifsjtu@review\relax\else + \cleardoublepage + \pdfbookmark[0]{\sjtu@label@authorization}{authtitle} + \IfNoValueTF{#1}{% + \thispagestyle{empty} + \chapter*{\zihao{-2}\sjtu@label@schoolChi \\% + \sjtu@label@authtitle} + \begingroup + \zihao{4} + \sjtu@label@authbody + \vskip 1ex + \sjtu@authconf + \vskip 16ex + \noindent + \begin{minipage}{\textwidth} + \sjtu@signbox{\sjtu@label@thesiscat 作者} + \hfill + \sjtu@signbox{指导教师} + \end{minipage} + \endgroup + } + {\includepdf[pagecommand={\thispagestyle{empty}}]{#1}} + \cleardoublepage + \fi +} +\NewDocumentEnvironment{nomenclature}{m}{% + \cleardoublepage + \pdfbookmark[0]{\sjtu@label@nomenclature}{nomenclature} + \chapter*{\sjtu@label@nomenclature} + \@mkboth{\sjtu@label@nomenclature}% + {\sjtu@label@nomenclature}% + \begin{longtable}{#1} +}{\end{longtable}} +\NewDocumentEnvironment{summary}{}{% + \cleardoublepage + \chapter*{\sjtu@label@summary} + \@mkboth{\sjtu@label@summary}% + {\sjtu@label@summary}% + \addcontentsline{toc}{chapter}{\sjtu@label@summary}% +}{} +\newcommand{\sjtu@acknowledgements}[1]{\long\gdef\sjtu@acknowledgements@body{#1}} +\NewDocumentEnvironment{acknowledgements}{}{% + \Collect@Body\sjtu@acknowledgements +}{% + \ifsjtu@review\relax\else + \cleardoublepage + \chapter*{\sjtu@label@acknowledgements} + \@mkboth{\sjtu@label@acknowledgements}% + {\sjtu@label@acknowledgements}% + \addcontentsline{toc}{chapter}{\sjtu@label@acknowledgements}% + \sjtu@acknowledgements@body + \fi +} +\newenvironment{sjtu@bibliolist}[2]{% + \cleardoublepage + \chapter{#2} + \@mkboth{#2}{#2}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m +}{% + \def\@noitemerr + {\@latex@warning{Empty `bibliolist' environment}}% + \endlist +} +\newcommand{\sjtu@publications}[1]{\long\gdef\sjtu@publications@body{#1}} +\NewDocumentEnvironment{publications}{O{99}}{% + \Collect@Body\sjtu@publications +}{% + \ifsjtu@review\relax\else + \begin{sjtu@bibliolist}{#1}{\sjtu@label@publications} + \sjtu@publications@body + \end{sjtu@bibliolist} + \fi +} +\newcommand{\sjtu@@publications}[1]{\long\gdef\sjtu@@publications@body{#1}} +\NewDocumentEnvironment{publications*}{O{99}}{% + \Collect@Body\sjtu@@publications +}{% + \ifsjtu@review + \begin{sjtu@bibliolist}{#1}{\sjtu@label@publications} + \sjtu@@publications@body + \end{sjtu@bibliolist} + \fi +} +\newcommand{\sjtu@projects}[1]{\long\gdef\sjtu@projects@body{#1}} +\NewDocumentEnvironment{projects}{O{99}}{% + \Collect@Body\sjtu@projects +}{% + \ifsjtu@review\relax\else + \begin{sjtu@bibliolist}{#1}{\sjtu@label@projects} + \sjtu@projects@body + \end{sjtu@bibliolist} + \fi +} +\newcommand{\sjtu@@projects}[1]{\long\gdef\sjtu@@projects@body{#1}} +\NewDocumentEnvironment{projects*}{O{99}}{% + \Collect@Body\sjtu@@projects +}{% + \ifsjtu@review + \begin{sjtu@bibliolist}{#1}{\sjtu@label@projects} + \sjtu@@projects@body + \end{sjtu@bibliolist} + \fi +} +\newcommand{\sjtu@patents}[1]{\long\gdef\sjtu@patents@body{#1}} +\NewDocumentEnvironment{patents}{O{99}}{% + \Collect@Body\sjtu@patents +}{% + \ifsjtu@review\relax\else + \begin{sjtu@bibliolist}{#1}{\sjtu@label@patents} + \sjtu@patents@body + \end{sjtu@bibliolist} + \fi +} +\newcommand{\sjtu@@patents}[1]{\long\gdef\sjtu@@patents@body{#1}} +\NewDocumentEnvironment{patents*}{O{99}}{% + \Collect@Body\sjtu@@patents +}{% + \ifsjtu@review + \begin{sjtu@bibliolist}{#1}{\sjtu@label@patents} + \sjtu@@patents@body + \end{sjtu@bibliolist} + \fi +} +\newcommand{\sjtu@resume}[1]{\long\gdef\sjtu@resume@body{#1}} +\NewDocumentEnvironment{resume}{}{% + \Collect@Body\sjtu@resume +}{% + \ifsjtu@review\relax\else + \cleardoublepage + \chapter{\sjtu@label@resume} + \@mkboth{\sjtu@label@resume}% + {\sjtu@label@resume}% + \sjtu@resume@body + \fi +} +\AtBeginDocument{ + \ifsjtu@review% + \sjtuSetInfo{% + author={}, + supervisor={}, + assisupervisor={}, + enauthor={}, + ensupervisor={}, + enassisupervisor={}, + studentid={}, + date={}, + endate={} + } + \fi + \hypersetup{% + pdftitle = \sjtu@value@title, + pdfauthor = \sjtu@value@author, + pdfsubject = \sjtu@label@subjectChi, + pdfkeywords = \sjtu@value@keywords, + pdfcreator = {LaTeX with SJTUThesis \version} + }% +} +\NewDocumentCommand{\encrypt}{m O{***}}{% + \ifsjtu@review + {#2} + \else + {#1} + \fi +} +\newcommand{\sjtu@uline}[1]{% + \begingroup + \setbox0=\vbox{\strut #1\strut}% + \dimen0=0pt + \loop\ifdim\ht0>0pt + \dimen1=\dimexpr\ht0 - \baselineskip\relax + \setbox1=\vsplit0 to \ht\strutbox + \advance\dimen1 by -\ht0 + \noindent\raisebox{-\dimen0}[\ht\strutbox][\dp\strutbox]{\box1}% + \advance\dimen0 by \dimen1 + \vspace{-0.2ex}\hrule\vskip 0.2ex + \repeat + \endgroup +} +\hypersetup{ + linktoc = all, + bookmarksnumbered = true, + bookmarksopen = true, + bookmarksopenlevel = 1, + unicode = true, + psdextra = true, + breaklinks = true, + plainpages = false, + hidelinks, +} +\pdfstringdefDisableCommands{% + \let\\\@empty + \let\quad\@empty + \let\hspace\@gobble +} +\urlstyle{same} +\def\UrlBreaks{% + \do\/% + \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l% + \do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z% + \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L% + \do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z% + \do0\do1\do2\do3\do4\do5\do6\do7\do8\do9\do=\do/\do.\do:% + \do\*\do\-\do\~\do\'\do\"\do\-} +\Urlmuskip=0mu plus 0.1mu +\newcommand{\sjtu@atendpackage}{\csname ctex_at_end_package:nn\endcsname} +\sjtu@atendpackage{unicode-math}{ + \newcommand{\bm}{\symbf} + \renewcommand{\boldsymbol}{\symbf} + \newcommand{\square}{\mdlgwhtsquare} + \@ifpackagelater{hyperref}{2019/04/27}{}{% + \g@addto@macro\psdmapshortnames{\let\mu\textmugreek}% + } +} +\sjtu@atendpackage{threeparttable}{ + \appto\TPTnoteSettings{\footnotesize} +} +\sjtu@atendpackage{siunitx}{ + \sisetup{ + detect-all, + group-minimum-digits = 4, + separate-uncertainty = true, + inter-unit-product = \ensuremath{{}\cdot{}}, + } + \ifsjtu@language@chinese + \sisetup{ + list-final-separator = { 和 }, + list-pair-separator = { 和 }, + range-phrase = {~}, + } + \fi +} +\PassOptionsToPackage{amsmath,thmmarks,hyperref}{ntheorem} +\sjtu@atendpackage{ntheorem}{ + \ifsjtu@language@chinese + \def\sjtu@label@assertion{断言} + \def\sjtu@label@assumption{假设} + \def\sjtu@label@axiom{公理} + \def\sjtu@label@corollary{推论} + \def\sjtu@label@definition{定义} + \def\sjtu@label@example{例} + \def\sjtu@label@lemma{引理} + \def\sjtu@label@proof{证明} + \def\sjtu@label@proposition{命题} + \def\sjtu@label@remark{注} + \def\sjtu@label@theorem{定理} + \else + \def\sjtu@label@assertion{Assertion} + \def\sjtu@label@assumption{Assumption} + \def\sjtu@label@axiom{Axiom} + \def\sjtu@label@corollary{Corollary} + \def\sjtu@label@definition{Definition} + \def\sjtu@label@example{Example} + \def\sjtu@label@lemma{Lemma} + \def\sjtu@label@proof{Proof} + \def\sjtu@label@proposition{Proposition} + \def\sjtu@label@remark{Remark} + \def\sjtu@label@theorem{Theorem} + \fi + \theoremheaderfont{\bfseries\heiti} + \theorembodyfont{\normalfont} + \theoremseparator{\enskip} + \theoremsymbol{\ensuremath{\square}} + \newtheorem*{proof}{\sjtu@label@proof} + \theoremstyle{plain} + \theoremsymbol{} + \newtheorem{theorem} {\sjtu@label@theorem} [chapter] + \newtheorem{assertion} [theorem]{\sjtu@label@assertion} + \newtheorem{axiom} [theorem]{\sjtu@label@axiom} + \newtheorem{corollary} [theorem]{\sjtu@label@corollary} + \newtheorem{lemma} [theorem]{\sjtu@label@lemma} + \newtheorem{proposition}[theorem]{\sjtu@label@proposition} + \newtheorem{assumption} {\sjtu@label@assumption} [chapter] + \newtheorem{definition} {\sjtu@label@definition} [chapter] + \newtheorem{example} {\sjtu@label@example} [chapter] + \newtheorem*{remark} {\sjtu@label@remark} +} +\sjtu@atendpackage{amsthm}{ + \ifsjtu@language@chinese + \def\sjtu@label@assertion{断言} + \def\sjtu@label@assumption{假设} + \def\sjtu@label@axiom{公理} + \def\sjtu@label@corollary{推论} + \def\sjtu@label@definition{定义} + \def\sjtu@label@example{例} + \def\sjtu@label@lemma{引理} + \def\sjtu@label@proof{证明} + \def\sjtu@label@proposition{命题} + \def\sjtu@label@remark{注} + \def\sjtu@label@theorem{定理} + \else + \def\sjtu@label@assertion{Assertion} + \def\sjtu@label@assumption{Assumption} + \def\sjtu@label@axiom{Axiom} + \def\sjtu@label@corollary{Corollary} + \def\sjtu@label@definition{Definition} + \def\sjtu@label@example{Example} + \def\sjtu@label@lemma{Lemma} + \def\sjtu@label@proof{Proof} + \def\sjtu@label@proposition{Proposition} + \def\sjtu@label@remark{Remark} + \def\sjtu@label@theorem{Theorem} + \fi + \newtheoremstyle{sjtuplain} + {}{} + {\normalfont}{} + {\bfseries\heiti}{} + {\ccwd}{} + \theoremstyle{sjtuplain} + \newtheorem{theorem} {\sjtu@label@theorem} [chapter] + \newtheorem{assertion} [theorem]{\sjtu@label@assertion} + \newtheorem{axiom} [theorem]{\sjtu@label@axiom} + \newtheorem{corollary} [theorem]{\sjtu@label@corollary} + \newtheorem{lemma} [theorem]{\sjtu@label@lemma} + \newtheorem{proposition}[theorem]{\sjtu@label@proposition} + \newtheorem{assumption} {\sjtu@label@assumption} [chapter] + \newtheorem{definition} {\sjtu@label@definition} [chapter] + \newtheorem{example} {\sjtu@label@example} [chapter] + \newtheorem*{remark} {\sjtu@label@remark} + \renewcommand\proofname\sjtu@label@proof + \renewenvironment{proof}[1][\proofname]{\par + \pushQED{\qed}% + \normalfont \topsep6\p@\@plus6\p@\relax + \trivlist + \item\relax + {\bfseries\heiti #1~} + \hspace\labelsep\ignorespaces + }{% + \popQED\endtrivlist\@endpefalse + } +} +\PassOptionsToPackage{algochapter}{algorithm2e} +\sjtu@atendpackage{algorithm2e}{ + \SetAlgorithmName{\sjtu@label@algorithm}% + {\sjtu@label@algorithm}% + {\sjtu@label@listalgorithm} + \SetAlgoCaptionSeparator{~} + \newcommand{\cftalgpresnum}{\sjtu@label@algorithm~} + \AtEndPreamble{% + \newlength{\cftalgindent} + \setlength{\cftalgindent}{1.5em} + \newlength{\cftalgnumwidth} + \setlength{\cftalgnumwidth}{2.3em} + \newlength{\sjtu@cftalgnumwidth@tmp} + \settowidth{\sjtu@cftalgnumwidth@tmp}{\cftalgpresnum} + \addtolength{\cftalgnumwidth}{\sjtu@cftalgnumwidth@tmp} + } + \renewcommand*{\l@algocf}{% + \let\@cftbsnum \cftalgpresnum + \@dottedtocline{1}{\cftalgindent}{\cftalgnumwidth} + } + \renewcommand{\listofalgorithms}{% + \cleardoublepage% + \pdfbookmark[0]{\listalgorithmcfname}{loa}% + \chapter*{\listalgorithmcfname}% + \@mkboth{\listalgorithmcfname}{\listalgorithmcfname}% + \@starttoc{loa} + } + \AtBeginDocument{% + \renewcommand{\thealgocf}{\thechapter--\@arabic\c@algocf} + } +} +\sjtu@atendpackage{algorithm}{ + \RequirePackage{algorithmicx, algpseudocode} + \floatname{algorithm}{\sjtu@label@algorithm} + \@addtoreset{algorithm}{chapter} + \patchcmd\@chapter% + {\if@twocolumn} + {\addtocontents{loa}{\protect\addvspace{10\p@}}% + \if@twocolumn} + {}{} + \renewcommand{\listalgorithmname}{\sjtu@label@listalgorithm} + \newcommand{\cftalgpresnum}{\sjtu@label@algorithm~} + \AtEndPreamble{% + \newlength{\cftalgindent} + \setlength{\cftalgindent}{1.5em} + \newlength{\cftalgnumwidth} + \setlength{\cftalgnumwidth}{2.3em} + \newlength{\sjtu@cftalgnumwidth@tmp} + \settowidth{\sjtu@cftalgnumwidth@tmp}{\cftalgpresnum} + \addtolength{\cftalgnumwidth}{\sjtu@cftalgnumwidth@tmp} + } + \newcommand*{\l@algorithm}{% + \let\@cftbsnum \cftalgpresnum + \@dottedtocline{1}{\cftalgindent}{\cftalgnumwidth} + } + \renewcommand{\listofalgorithms}{% + \cleardoublepage% + \pdfbookmark[0]{\listalgorithmname}{loa}% + \chapter*{\listalgorithmname}% + \@mkboth{\listalgorithmname}{\listalgorithmname}% + \@starttoc{loa} + } + \AtBeginDocument{% + \renewcommand{\thealgorithm}{\thechapter--\arabic{algorithm}} + } +} +\sjtu@atendpackage{listings}{ + \lstdefinestyle{lstStyleCode}{ + aboveskip=\medskipamount, + belowskip=\medskipamount, + basicstyle=\footnotesize\ttfamily, + commentstyle=\slshape\color{black!60}, + stringstyle=\color{green!40!black!100}, + keywordstyle=\bfseries\color{blue!50!black}, + extendedchars=false, + upquote=true, + tabsize=2, + showstringspaces=false, + xleftmargin=1em, + xrightmargin=1em, + breaklines=true, + breakindent=2em, + framexleftmargin=1em, + framexrightmargin=1em, + backgroundcolor=\color{gray!10}, + columns=flexible, + keepspaces=true, + texcl=true, + mathescape=true + } + \lstnewenvironment{codeblock}[1][] + {\lstset{style=lstStyleCode,#1}}{} +} +\sjtu@atendpackage{tikz}{ + \usetikzlibrary{shapes.geometric, arrows} + \tikzstyle{startstop} = [ + rectangle, + rounded corners, + minimum width=2cm, + minimum height=1cm, + text centered, + draw=black + ] + \tikzstyle{io} = [ + trapezium, + trapezium left angle=75, + trapezium right angle=105, + minimum width=1cm, + minimum height=1cm, + text centered, + draw=black + ] + \tikzstyle{process} = [ + rectangle, + minimum width=2cm, + minimum height=1cm, + text centered, + draw=black + ] + \tikzstyle{decision} = [ + diamond, + minimum width=2cm, + minimum height=1cm, + text centered, + draw=black] + \tikzstyle{arrow} = [thick, ->, >=stealth] +} +\endinput +%% +%% End of file `sjtuthesis.cls'. diff --git a/sample/sjtuthesis.sty b/sjtuthesis.sty similarity index 100% rename from sample/sjtuthesis.sty rename to sjtuthesis.sty diff --git a/source/sample.mk b/source/sample.mk deleted file mode 100644 index ed1be526..00000000 --- a/source/sample.mk +++ /dev/null @@ -1,46 +0,0 @@ -# Makefile for SJTUThesis - -# Basename of thesis -THESIS = thesis - -# Option for latexmk -LATEXMK_OPT = -xelatex -quiet -file-line-error -halt-on-error -interaction=nonstopmode -LATEXMK_OPT_PVC = $(LATEXMK_OPT_BASE) -pvc - -# make deletion work on Windows -ifdef SystemRoot - RM = del /Q - OPEN = start -else - RM = rm -f - OPEN = open -endif - -.PHONY : all pvc view wordcount clean cleanall FORCE_MAKE - -all : $(THESIS).pdf - -$(THESIS).pdf : $(THESIS).tex FORCE_MAKE - @latexmk $(LATEXMK_OPT) $< - -pvc : $(THESIS).tex - @latexmk $(LATEXMK_OPT_PVC) $(THESIS) - -view : $(THESIS).pdf - $(OPEN) $< - -wordcount : $(THESIS).tex - @if grep -v ^% $< | grep -qz '\\documentclass\[[^\[]*english'; then \ - texcount $< -inc -char-only | awk '/total/ {getline; print "英文字符数\t\t\t:",$$4}'; \ - else \ - texcount $< -inc -ch-only | awk '/total/ {getline; print "纯中文字数\t\t\t:",$$4}'; \ - fi - @texcount $< -inc -chinese | awk '/total/ {getline; print "总字数(英文单词 + 中文字)\t:",$$4}' - -clean : - -@latexmk -c -silent $(THESIS).tex 2> /dev/null - -@rm -f $(TEX_DIR)/*.aux 2> /dev/null || true - -cleanall : - -@latexmk -C -silent $(THESIS).tex 2> /dev/null - -@rm -f $(TEX_DIR)/*.aux 2> /dev/null || true diff --git a/source/sjtuthesis.dtx b/source/sjtuthesis.dtx deleted file mode 100644 index 900ec1df..00000000 --- a/source/sjtuthesis.dtx +++ /dev/null @@ -1,2442 +0,0 @@ -% \iffalse meta-comment -% -% Copyright (C) 2009-2017 by weijianwen -% (C) 2018-2019 by SJTUG -% -% This file may be distributed and/or modified under the -% conditions of the LaTeX Project Public License, either version 1.3c -% of this license or (at your option) any later version. -% The latest version of this license is in -% https://www.latex-project.org/lppl.txt -% and version 1.3c or later is part of all distributions of LaTeX -% version 2005/12/01 or later. -% -% This file has the LPPL maintenance status "maintained". -% -% The Current Maintainer of this work is Alexara Wu. -% -%<*internal> -\begingroup - \def\nameoflatex{LaTeX2e} -\expandafter\endgroup\ifx\nameoflatex\fmtname\else -\csname fi\endcsname -% -%<*install> -\input docstrip.tex -\keepsilent -\askforoverwritefalse - -\preamble - -Copyright (C) 2009-2017 by weijianwen - (C) 2018-\the\year by SJTUG - -This file may be distributed and/or modified under the -conditions of the LaTeX Project Public License, either version 1.3c -of this license or (at your option) any later version. -The latest version of this license is in - https://www.latex-project.org/lppl.txt -and version 1.3c or later is part of all distributions of LaTeX -version 2005/12/01 or later. - -This file has the LPPL maintenance status "maintained". - -The Current Maintainer of this work is Alexara Wu. - -\endpreamble - -\generate{ - \usedir{tex/latex/sjtuthesis} - \file{\jobname.cls} {\from{\jobname.dtx}{class}} - \file{\jobname-bachelor.ltx}{\from{\jobname.dtx}{bachelor}} - \file{\jobname-graduate.ltx}{\from{\jobname.dtx}{graduate}} - \file{sjtudoc.cls} {\from{\jobname.dtx}{document}} -% -%<*internal> - \usedir{source/latex/sjtuthesis} - \file{\jobname.ins} {\from{\jobname.dtx}{install}} -% -%<*install> -} - -\Msg{* Happy TeXing!} - -\endbatchfile -% -%<*internal> -\fi -% -%<*driver> -\ProvidesFile{sjtuthesis.dtx} -% -%\NeedsTeXFormat{LaTeX2e} -%\ProvidesClass{sjtuthesis} -%\ProvidesClass{sjtudoc} -%\ProvidesFile{sjtuthesis-bachelor.ltx} -%\ProvidesFile{sjtuthesis-graduate.ltx} -%<*(class|bachelor|graduate|document)> - [2019/06/16 1.0.0rc Shanghai Jiao Tong University Thesis Template] -% -%<*(document|class)> -\hyphenation{SJTU-Thesis} -\def\sjtuthesis{SJTU\textsc{Thesis}} -\def\version{1.0.0rc} -% -%<*driver> -\documentclass{sjtudoc} -\EnableCrossrefs -\CodelineIndex -\RecordChanges -% \OnlyDescription -\begin{document} - \DocInput{\jobname.dtx} - \clearpage - \PrintChanges - \clearpage - \PrintIndex -\end{document} -% -% \fi -% -% \DoNotIndex{\def,\long,\edef,\xdef,\gdef,\let,\global} -% \DoNotIndex{\if,\ifnum,\ifdim,\ifcat,\ifmmode,\ifvmode,\ifhmode,% -% \iftrue,\iffalse,\ifvoid,\ifx,\ifeof,\ifcase,\else,\or,\fi} -% \DoNotIndex{\begin,\end,\bgroup,\egroup,\begingroup,\endgroup} -% \DoNotIndex{\expandafter,\csname,\endcsname} -% \DoNotIndex{\hsize,\vsize,\hskip,\vskip,\kern,\hfil,\hfill,\hss} -% \DoNotIndex{\hspace,\vspace} -% \DoNotIndex{\p@,\m@ne,\z@,\@ne,\tw@,\@plus,\@minus} -% \DoNotIndex{\newcounter,\setcounter,\addtocounter,} -% \DoNotIndex{\newdim,\newlength,\setlength,\addtolength} -% \DoNotIndex{\newcommand,\renewcommand,\providecommand,\DeclareRobustCommand} -% \DoNotIndex{\newenvironment,\renewenvironment} -% \DoNotIndex{\RequirePackage,\LoadClass,\ProvidesClass} -% \DoNotIndex{\DeclareOption,\CurrentOption,\ExecuteOptions,\ProcessOptions} -% \DoNotIndex{\rmfamily,\sffamily,\ttfamily,\bfseries,\mdseries,\itshape,% -% \textrm,\textsf,\texttt,\textbf,\textmd,\textit,\textsl,\textsc} -% \DoNotIndex{\iint,\iiint,\iiiint,\oint,\oiint,\oiiint,% -% \intclockwise,\varointclockwise,\ointctrclockwise,\sumint,% -% \intbar,\intBar,\fint,\cirfnint,\awint,\rppolint,% -% \scpolint,\npolint,\pointint,\sqint,\intlarhk,\intx,% -% \intcap,\intcup,\upint,\lowint} -% \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,% -% \m,\n,\o,\p,\q,\r,\s,\t,\u,\v,\w,\x,\y,\z,% -% \A,\B,\C,\D,\E,\F,\G,\H,\I,\J,\K,\L,% -% \M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z,% -% \do\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\,,\!,\',\",\/,\*,\-} -% \DoNotIndex{\quad,\par,\relax,\ccwd} -% \DoNotIndex{\bp@} -% -% \GetFileInfo{\jobname.dtx} -% -% \changes{v0.10}{2018/01/09}{项目转移至 \href{https://github.com/sjtug/SJTUThesis}{SJTUG} 名下,并增加了英文模版,修改了默认字体设置。} -% \changes{v0.9.5}{2017/01/27}{改用 GB/7714-2015 参考文献风格。} -% \changes{v0.9.4}{2016/08/25}{增加算法和流程图。} -% \changes{v0.9}{2015/06/19}{适配 \pkg{ctex} 2.x 宏包,需要使用 TeXLive 2015 编译。} -% \changes{v0.8}{2015/03/15}{使用 \pkg{biber}/\pkg{biblatex} 组合替代 \BibTeX,带来更强大稳定的参考文献处理能力;添加 \pkg{enumitem} 宏包增强列表环境控制能力;完善宏包文字描述。} -% \changes{v0.7}{2015/02/15}{增加盲审选项,调用外部工具插入扫描件。} -% \changes{v0.6.5}{2015/02/14}{修正一些小问题,缩减 git 仓库体积,仓库由 sjtu-thesis-template-latex 更名为 \sjtuthesis。} -% \changes{v0.6}{2014/12/17}{学士、硕士、博士学位论文模板合并在了一起。} -% \changes{v0.5.3}{2013/05/26}{更正 \env{subsubsection} 格式错误,这个错误导致如“1.1 小结”这样的标题没有被正确加粗。} -% \changes{v0.5.2}{2012/12/27}{更正拼写错误。在 \file{diss.tex} 加入 \file{ack.tex}。} -% \changes{v0.5.1}{2012/12/21}{在 \LaTeX\ 命令和中文字符之间留了空格,在 \file{Makefile} 中增加 release 功能。} -% \changes{v0.5}{2012/12/05}{修改说明文件的措辞,更正 \file{Makefile} 文件,使用 \pkg{metalog} 宏包替换 \pkg{xltxtra} 宏包,使用 \pkg{mathtools} 宏包替换 \pkg{amsmath} 宏包,移除了所有 CJKtilde 符号。} -% \changes{v0.4}{2012/05/30}{包含交大学士、硕士、博士学位论文模板。模板在 \href{https://github.com/weijianwen/SJTUThesis}{GitHub} 上管理和更新。} -% \changes{v0.3a}{2010/12/05}{移植到 \XeTeX/\LaTeX 上。} -% \changes{v0.2a}{2009/12/25}{模板由 \cls{CASthesis} 改名为 \cls{sjtumaster}。在 \file{diss.tex} 中可以方便地改变正文字号、切换但双面打印。增加了不编号的一章“全文总结”。添加了可伸缩符号(等号、箭头)的例子,增加了长标题换行的例子。} -% \changes{v0.1c}{2009/11/20}{增加了 Linux 下使用 \pkg{ctex} 宏包的注意事项、\file{bib} 条目的规范要求,修正了 \pkg{ctexbook} 与 \pkg{listings} 共同使用时的断页错误。} -% \changes{v0.1b}{2009/11/13}{完善了模板使用说明,增加了定理环境、并列子图、三线表格的例子。} -% \changes{v0.1a}{2009/11/12}{上海交通大学硕士学位论文 \LaTeX\ 模板发布。} -% -% \title{\bfseries\color{sjtublue}\sjtuthesis:上海交通大学学位论文模板} -% \author{\href{https://sjtug.org/}{SJTUG}} -% \date{\filedate\qquad v\fileversion} -% -% \maketitle -% \thispagestyle{empty} -% \vspace{\stretch{1}} -% \begin{center} -% \includegraphics[height=4cm]{sjtu-badge.pdf} -% \end{center} -% \vspace{\stretch{1}} -% \begin{abstract} -% 此宏包旨在建立一个简单易用的上海交通大学论文模板,包括学士、硕士、博士学位论文 -% 以及普通课程论文。 -% \end{abstract} -% \vspace{\stretch{1}} -% \def\abstractname{免责声明} -% \begin{abstract} -% \noindent -% \begin{enumerate} -% \item 本模板的发布遵守 \LaTeX\ Project Public License,使用前请认真阅读协议内 -% 容。 -% \item 本模板根据 \href{https://www.gs.sjtu.edu.cn/info/1143/5801.htm} -% {《上海交通大学博士、硕士学位论文撰写指南》} 以及 -% \href{http://bysj.jwc.sjtu.edu.cn/shownews.aspx?newsno=C1uSkpxqiKCad13AzOcvQA....} -% {《上海交通大学本科生毕业设计(论文)撰写规范》} 编写而成,同时参考了 -% \href{http://jdgs.sjtu.edu.cn/uploads/%E5%AD%A6%E4%BD%8D%E8%AE%BA%E6%96%87-%E7%AD%94%E8%BE%A9%E7%94%B3%E8%AF%B7%E6%B5%81%E7%A8%8B/11%E5%AD%A6%E4%BD%8D%E8%AE%BA%E6%96%87%E6%A0%BC%E5%BC%8F%E7%9A%84%E7%BB%9F%E4%B8%80%E8%A6%81%E6%B1%82.docx} -% {《上海交通大学研究生学位论文格式的统一要求》}。旨在供上海交通大学准毕业生撰 -% 写学位论文使用。 -% \item 此模板仅为撰写指南的参考实现,不保证审查老师不提意见。任何由于使用本模板 -% 而引起的论文格式审查问题均与本模板作者无关。 -% \item 任何个人或组织以本模板为基础进行修改、扩展而生成的新的专用模板,请严格遵 -% 守 \LaTeX\ Project Public License 协议。由于违犯协议而引起的任何纠纷争端均与 -% 本模板作者无关。 -% \end{enumerate} -% \end{abstract} -% \vspace{\stretch{3}} -% -% \clearpage -% \begin{multicols}{2}[ -% \setlength{\columnseprule}{.4pt} -% \setlength{\columnsep}{18pt}] -% \tableofcontents -% \end{multicols} -% \clearpage -% -% \section{介绍} -% -% 这是为撰写上海交通大学学士、硕士、博士学位论文以及课程论文而准备的 \LaTeX\ 模 -% 板。 -% -% 最早的一版学位模板由一位热心的物理系同学制作,中文字符处理采用了当时最为流行的 -% \CJKLaTeX\ 方案。在此基础上,weijianwen 根据交大研究生院对学位论文的要求,完成 -% 了一份基本可用的交大 \LaTeX\ 学位论文模板。由于 \CJKLaTeX\ 方案不易使用, -% weijianwen 与 William Wang 开始着手把模板向\XeTeX\ 引擎移植。之后 weijianwen -% 又断断续续做了一些完善模板的工作,在原有硕士学位论文模板的基础上完成了交大学士 -% 和博士学位论文模板。 -% -% 2012 年 5 月模板开始在 GitHub 上管理和更新,2018 年 1 月项目转移至 SJTUG 名 -% 下。2019 年 6 月 Alexara Wu 重构了整个宏包的代码,并使用 doc 和 DocStrip 工具 -% 进行代码的管理,升级版本号为 1.0。 -% -% 本文档将尽量完整的介绍模板的使用方法,如有不清楚之处可以参考示例文档或者根据 -% 第~\ref{sec:howtoask} 节说明提问,有兴趣者都可以参与完善此手册,也非常欢迎对代 -% 码的贡献。 -% -% \note{模板的作用在于减少论文写作过程中格式调整的时间,前提是遵守模板的用法,否 -% 则即便用了\sjtuthesis 也难以保证输出的论文符合学校规范。} -% -% \section{安装} -% -% \subsection{获取 \sjtuthesis} -% -% 你可以在 \href{https://github.com/sjtug/SJTUThesis/releases}{GitHub Release} -% 中找到 \sjtuthesis 的所有版本,推荐使用最新版本以避免一些问题。 -% -% \subsection{文件组成} -% -% 表~\ref{tab:files} 列出了 \sjtuthesis 的主要文件及其功能介绍。 -% -% \begin{table}[!hbt] -% \centering -% \caption{模板的文件组成} -% \label{tab:files} -% \begin{tabular}{lll} -% \toprule -% 类别 & 文件 & 说明 \\ -% \midrule -% 源文件 & \file{sjtuthesis.dtx} & 模板源代码文件 (开发用) \\ -% \midrule -% 生成文件 & \file{sjtuthesis.cls} & 文档类文件 \\ -% & \file{sjtuthesis-*.ltx} & 文档类辅助文件 \\ -% & \file{sjtu-*.pdf} & 校徽、校名图片 \\ -% & \file{sjtuthesis.pdf} & 用户手册 (本文档) \\ -% \midrule -% 示例文档 & \file{thesis.tex} & 主文档 \\ -% & \file{tex/*.tex} & 示例文档的各个章节 \\ -% & \file{figure/} & 图片目录 \\ -% & \file{bib/*.bib} & 参考文献目录 \\ -% \midrule -% 其他 & \file{README.md} & 基本说明 \\ -% & \file{latexmkrc} & latexmk 的配置文件 \\ -% & \file{Makefile} & GNU make 的配置文件 \\ -% \bottomrule -% \end{tabular} -% \end{table} -% -% \subsection{编译模板} -% \label{sec:process} -% -% 本节介绍几种常见的编译模板生成论文的方法。用户可根据自己的情况选择。 -% -% \subsubsection{\texorpdfstring{\XeLaTeX}{XeLaTeX}} -% -% 很多用户对 \LaTeX\ 命令执行的次数不太清楚。一个基本的原则是多次运行 \LaTeX\ 命 -% 令直至不再出现警告。下面给出生成示例文档的详细过程(\# 开头的行为注释),首先 -% 来看的 \XeLaTeX\ 方式: -% -% \begin{shell} -% # 1.发现文件中的引用关系,文件后缀 .tex 可省略 -% xelatex thesis -% # 2.编译参考文件源文件,生成 .bbl 文件 -% biber thesis -% # 3.解决文件中的交叉引用 -% xelatex thesis -% # 4.生成完整的 pdf 文件 -% xelatex thesis -% # 5.更新目录 -% xelatex thesis -% \end{shell} -% -% \subsubsection{latexmk} -% \label{sec:latexmk} -% -% \texttt{latexmk} 命令支持全自动生成 \LaTeX\ 编写的文档,并且支持使用不同的工具 -% 链来进行生成,它会自动运行多次工具直到交叉引用都被解决。下面给出了一个用 -% \texttt{latexmk} 调用 \texttt{xelatex} 生成最终文档的示例: -% -% \begin{shell} -% # 一句话就够了! -% latexmk -xelatex thesis -% \end{shell} -% -% \subsubsection{make} -% \label{sec:make} -% -% 上面的方法虽然不复杂,但是每次都输入还是非常罗嗦,所以 \sjtuthesis 提供了一 -% 个 \file{Makefile}: -% -% \begin{shell} -% make thesis.pdf # 生成示例文档 thesis.pdf -% make clean -% make cleanall -% \end{shell} -% -% \sjtuthesis 的 \file{Makefile} 默认用 \texttt{latexmk} 调用\texttt{xelatex} 编 -% 译。如有需要可修改 \file{Makefile} 开头的参数或通过命令行传递参数,进一步还可 -% 以修改 \file{.latexmkrc} 进行定制。 -% -% \section{使用说明} -% -% 本手册假定用户已经能处理一般的 \LaTeX\ 文档,并对 \BibLaTeX\ 有一定了解。如果 -% 从来没有接触过 \TeX\ 和 \LaTeX,建议先学习相关的基础知识。 -% -% \subsection{关于提问} -% \label{sec:howtoask} -% 按照优先级推荐提问的位置如下: -% -% \begin{itemize} -% \item \href{https://github.com/sjtug/SJTUThesis/issues}{Github Issues} -% \item \href{https://bbs.sjtu.edu.cn/bbsdoc?board=TeX_LaTeX}{水源LaTeX版} -% \end{itemize} -% -% \subsection{示例文件} -% \label{sec:userguide} -% -% 模板核心文件有:\file{sjtuthesis.cls},\file{sjtuthesis-bachelor.ltx} 和 -% \file{sjtuthesis-graduate.ltx},但如果没有示例文档会很难下手,所以推荐从模板自 -% 带的示例文档入手,其中包括了论文写作用到的所有命令及其使用方法,只需要用自己的 -% 内容进行相应替换就可以。对于不清楚的命令可以查阅本手册。下面的例子描述了模板中 -% 章节的组织形式,来自于示例文档,具体内容可以参考模板附带的 \file{thesis.tex} -% 和 \file{tex/}。 -% -% \lstinputlisting[style=lstStyleLaTeX]{thesis.tex} -% -% \subsection{文档类选项} -% -% \DescribeOption{degree=\meta{degree}} -% 选择论文类型,当前支 -% 持:\opt{bachelor},\opt{master},\opt{doctor},\opt{course}。 -% 为必选项。 -% \begin{latex} -% % 博士论文 -% \documentclass[degree=doctor]{sjtuthesis} -% -% % 硕士论文 -% \documentclass[degree=master]{sjtuthesis} -% \end{latex} -% -% \DescribeOption{language=\meta{language}} -% 论文的主要语言(默认:中文)。可选:\opt{chinese},\opt{english}。 -% -% \DescribeOption{mathstyle=\meta{style}} -% 数学字体风格(默认:GB)。仅在 \pkg{unicode-math} 启用时有效。 -% 可选:\opt{GB}, \opt{ISO},\opt{TeX}。 -% -% \DescribeOption{bibstyle=\meta{style}} -% 参考文献样式(默认:gb7714-2015)。 -% 可选:\opt{gb7714-2015},\opt{gb7714-2015ay},\opt{ieee}。 -% -% \DescribeOption{review} -% 盲审模式开关(默认:关闭)。 -% -% \subsection{字体配置} -% -% 本模板默认以 \pkg{fontspec} + \pkg{unicode-math} + \pkg{xeCJK} 的方式来配置字 -% 体。 -% -% \subsubsection{西文字体} -% -% \DescribeOption{setlatinfont=\meta{scope}} -% 模板默认使用 OpenType 西文字体。默认设置下,正文字体为 XITS,数学字体为 XITS -% Math,无衬线字体与等宽字体分别为 Source Sans Pro 与 Source Code Pro。 -% 用户可以在调用文档类时加入选项 -% \opt{setlatinfont=all/main/math/none} 控制西文字体的设置。默认为 \opt{all},同 -% 时设置正文字体和数学字体;\opt{main} 仅设置正文字体;\opt{math} 仅设置数学字 -% 体;也可以使用 \opt{none},然后自行配置西文字体。 -% -% \subsubsection{中文字体} -% -% \DescribeOption{fontset=\meta{font}} -% 模板默认使用 \CTeX 的字体配置。默认情况下,本模板可以自动检测操作系统,并配置 -% 合适的字体。 -% 用户可以在调用文档类时加入选项 -% \opt{fontset=mac/windows/adobe} 指定加载的字库, -% 也可以使用 \opt{fontset=none},然后自行配置中文字体。 -% -% 注意,Linux 系统下默认的中文字库 Fandol 容易出现缺字的情况。 -% 我们建议 Linux 用户自行配置合适的字体。 -% -% \subsubsection{字体命令} -% \label{sec:fontcmds} -% \DescribeMacro{\songti} -% \DescribeMacro{\fangsong} -% \DescribeMacro{\heiti} -% \DescribeMacro{\kaishu} -% 用来切换宋体、仿宋、黑体、楷体四种基本字体。 -% -% \begin{latex} -% {\songti 力微任重久神疲,} -% {\fangsong 再竭衰庸定不支。} -% {\heiti 苟利国家生死以,} -% {\kaishu 岂因祸福避趋之?} -% \end{latex} -% -% \DescribeMacro{\zihao\marg{num}} -% 用来切换字号大小。 -% -% \subsection{标题页信息} -% -% \DescribeMacro{\maketitle} -% 标题页可由 \cs{maketitle} 命令生成,其中的各项信息提供两种配置方法。 -% -% 一是使用 \cs{\meta{item}\marg{info}} 的方式独立设置各项信息, -% 本模板提供的命令如表~\ref{tab:covercmds}, -% 其中带 |en| 前缀的命令是 设置英文标题页的命令: -% \begin{table}[htb] -% \centering\small -% \caption{录入标题页信息的命令} -% \label{tab:covercmds} -% \begin{tabular}{lll} -% \toprule -% 命令 & 命令(英文) & 说明 \\ -% \midrule -% \cs{title} & \cs{entitle} & 论文标题 \\ -% \cs{keywords} & \cs{enkeywords} & 关键字 \\ -% \cs{author} & \cs{enauthor} & 作者姓名 \\ -% \cs{supervisor} & \cs{ensupervisor} & 导师姓名 \\ -% \cs{cosupervisor} & \cs{encosupervisor} & 副导师姓名 \\ -% \cs{degree} & \cs{endegree} & 申请学位 \\ -% \cs{department} & \cs{endepartment} & 院系 \\ -% \cs{major} & \cs{enmajor} & 学科专业 \\ -% \cs{coursename} & \cs{encoursename} & 课程名称 \\ -% \cs{fund} & \cs{enfund} & 资助基金 \\ -% \cs{date} & \cs{endate} & 答辩日期 \\ -% \cs{studentid} & - & 学号 \\ -% \bottomrule -% \end{tabular} -% \end{table} -% -% 二是通过统一设置命令 \cs{sjtuSetInfo} 通过\emph{key=value} 形式完成: -% \begin{latex} -% \sjtuSetInfo{ -% title = XXX, -% keywords = {AAA, BBB}, -% } -% % 可以多次调用 -% \sjtuSetInfo{ -% author = CCC, -% title = YYY, % 覆盖 XXX -% } -% \end{latex} -% -% \subsection{摘要和章节} -% -% 对于特殊的章节,\sjtuthesis 还提供了相应的环境: -% \begin{itemize} -% \item 中文摘要:\env{abstract} -% \DescribeEnv{abstract} -% \item 英文摘要:\env{enabstract} -% \DescribeEnv{enabstract} -% \item 符号说明:\env{nomenclature} -% \DescribeEnv{nomenclature} -% \item 致谢: \env{acknowledgements} -% \DescribeEnv{acknowledgements} -% \item 发表成果:\env{publications} -% \DescribeEnv{publications} -% \item 申请专利:\env{patents} -% \DescribeEnv{patents} -% \item 参与项目:\env{projects} -% \DescribeEnv{projects} -% \end{itemize} -% -% 目录和图、表清单可以使用命令自动生成: -% \begin{itemize} -% \item 目录: \cs{tableofcontents} -% \DescribeMacro{\tableofcontents} -% \item 图清单:\cs{listoffigures} -% \DescribeMacro{\listoffigures} -% \item 表清单:\cs{listoftables} -% \DescribeMacro{\listoftables} -% \end{itemize} -% -% \subsection{浮动体} -% -% 图题置于图的下方,表题置于表的上方。 -% \LaTeX{} 的 \cs{caption} 命令并不能控制在浮动体中的位置, -% 需要作者注意写在合适的地方。 -% -% 关于图片的并排,推荐使用较新的 \pkg{subcaption} 宏包,不建议使用 -% \pkg{subfigure} 或 \pkg{subfig}。 -% -% 更多的表格样式参见 \pkg{booktabs}(三线表)、\pkg{longtable}(跨页表格)。 -% -% 算法可以使用 \pkg{algorithms} 宏包或者较新的 \pkg{algorithm2e}。 -% -% \subsection{参考文献} -% -% 教务处要求参考文献外观应符合国家标准 GB/T7714。按照《GB/T 7714-2015》的规定, -% 参考文献的标注体系分为“顺序编码制”和“著者-出版年制”(authoryear)。 -% -% 模版默认使用顺序编码制,用户也可以按需要在文档类参数中设置样式,如: -% \begin{shell} -% \documentclass[degree=master, bibstyle=ieee]{sjtuthesis} -% \end{shell} -% -% \DescribeMacro{\cite} -% 在正文中引用文献时应使用 \cs{cite} 命令,可以产生上标引用的参考文献。 -% 同一处引用多篇文献时,需要将各篇文献的 key 一同写在参数中, -% 如 |\cite{Meta_CN,chen2007act,DPMG}|。 -% 它可以自动排序并用处理连续编号。 -% -% \DescribeMacro{\parencite} -% 需要临时将文献序号与正文平排,可以使用 \cs{parencite} 命令。 -% -% \DescribeMacro{\printbibliography} -% 参考文献表可以使用 \BibLaTeX\ 生成,其表现形式的控制逻辑通过 -% \pkg{biblatex-gb7714-2015} 实现。在文中使用 \cs{printbibliography} 命令输出参 -% 考文献表。添加参数 \opt{heading=bibintoc} 可将参考文献表加入目录。 -% -% \section{致谢} -% -% \sjtuthesis 模板的许多实现细节离不开 \href{https://github.com/sjtug/SJTUThesis/graphs/contributors} -% {热心同学们} 的贡献,在此感谢所有为模板贡献过代码的同学们, 以及所有测试和使用 -% 模板的各位同学! -% -% \section{实现细节} -% -% \begin{macrocode} -%<*class> -\RequirePackage{kvoptions} -\SetupKeyvalOptions{ - family=sjtu, - prefix=sjtu@, - setkeys=\kvsetkeys} -% \end{macrocode} -% -% 用 \pkg{kvoptions} 的 \texttt{key=value} 方式来设置论文类型。 -% \begin{macrocode} -\DeclareStringOption[doctor]{degree}[doctor] -% \end{macrocode} -% -% 论文是否使用英文。 -% \begin{macrocode} -\DeclareStringOption[chinese]{language}[chinese] -% \end{macrocode} -% -% 字号大小。 -% \begin{macrocode} -\DeclareStringOption[5]{zihao}[5] -% \end{macrocode} -% -% 设置西文字体方式。 -% \begin{macrocode} -\DeclareStringOption[all]{setlatinfont}[all] -% \end{macrocode} -% -% 数学字体风格。 -% \begin{macrocode} -\DeclareStringOption[GB]{mathstyle}[GB] -% \end{macrocode} -% -% 参考文献样式。 -% \begin{macrocode} -\DeclareStringOption[gb7714-2015]{bibstyle}[gb7714-2015] -% \end{macrocode} -% -% 盲审模式开关。 -% \begin{macrocode} -\DeclareBoolOption{review} -% \end{macrocode} -% -% 将选项传递给 \pkg{ctexbook}。 -% \begin{macrocode} -\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}} -% \end{macrocode} -% -% 解析用户传递过来的选项,并加载 \pkg{ctexbook}。 -% \begin{macrocode} -\ProcessKeyvalOptions* -\newcommand{\sjtu@validate@key}[1]{% - \@ifundefined{sjtu@#1@\csname sjtu@#1\endcsname true}{% - \ClassError{sjtuthesis}{Invalid value '\csname sjtu@#1\endcsname'}{}% - }{% - \csname sjtu@#1@\csname sjtu@#1\endcsname true\endcsname - }% -} -\newif\ifsjtu@degree@course -\newif\ifsjtu@degree@bachelor -\newif\ifsjtu@degree@master -\newif\ifsjtu@degree@doctor -\sjtu@validate@key{degree} -\ifsjtu@degree@course\sjtu@degree@bachelortrue\fi -\ifsjtu@degree@doctor\sjtu@degree@mastertrue\fi -\newif\ifsjtu@language@chinese -\newif\ifsjtu@language@english -\sjtu@validate@key{language} -\newif\ifsjtu@setlatinfont@none -\newif\ifsjtu@setlatinfont@main -\newif\ifsjtu@setlatinfont@math -\newif\ifsjtu@setlatinfont@all -\sjtu@validate@key{setlatinfont} -\ifsjtu@setlatinfont@all - \sjtu@setlatinfont@maintrue - \sjtu@setlatinfont@mathtrue -\fi -\newif\ifsjtu@mathstyle@GB -\@ifundefined{sjtu@mathstyle@\csname sjtu@mathstyle\endcsname true}{}{% - \sjtu@mathstyle@GBtrue - \def\sjtu@mathstyle{ISO} -} -\ifsjtu@language@english - \PassOptionsToClass{scheme=plain}{ctexbook} -\fi -% \end{macrocode} -% -% 使用 \XeTeX\ 引擎时,\pkg{fontspec} 宏包会被 \pkg{xeCJK} 自动调用。传递给 -% \pkg{fontspec} 宏包 \opt{no-math} 选项,避免部分数学符号字体自动调整为 CMR。 -% \begin{macrocode} -\PassOptionsToPackage{no-math}{fontspec} -% \end{macrocode} -% -% 传递数学字体风格设置给 \pkg{unicode-math}。 -% \begin{macrocode} -\PassOptionsToPackage{math-style=\sjtu@mathstyle}{unicode-math} -% \end{macrocode} -% -% 使用 \pkg{ctexbook} 类,优于调用 \pkg{ctex} 宏包。 -% \begin{macrocode} -\LoadClass[a4paper,zihao=\sjtu@zihao,linespread=1.3,UTF8]{ctexbook} -% \end{macrocode} -% -% 根据选项载入配置文件。 -% \begin{macrocode} -\ifsjtu@degree@bachelor - \AtEndOfClass{\input{sjtuthesis-bachelor.ltx}} -\else - \ifsjtu@degree@master - \AtEndOfClass{\input{sjtuthesis-graduate.ltx}} - \fi -\fi -% \end{macrocode} -% -% \subsection{载入宏包} -% -% 建议在模板开始处载入全部宏包,不要轻易改变加载顺序。\pkg{hyperref} 一般在最后 -% 加载。 -% \begin{macrocode} -\RequirePackage{etoolbox} -\RequirePackage{xparse} -\RequirePackage{environ} -% \end{macrocode} -% -% 使用 \pkg{geometry} 设置页面。 -% \begin{macrocode} -\RequirePackage{geometry} -% \end{macrocode} -% -% 使用 \pkg{fancyhdr} 设置页眉页脚。 -% \begin{macrocode} -\RequirePackage{fancyhdr} -% \end{macrocode} -% -% 使用 \pkg{pageslts} 设置页码格式。 -% \begin{macrocode} -\RequirePackage{pageslts} -% \end{macrocode} -% -% 使用 \pkg{amsmath} 处理数学公式。 -% \begin{macrocode} -\RequirePackage{amsmath} -% \end{macrocode} -% -% 字体相关宏包。 -% \begin{macrocode} -\ifsjtu@setlatinfont@math - \RequirePackage{unicode-math} -\fi -\RequirePackage{anyfontsize} -% \end{macrocode} -% -% 颜色支持宏包。 -% \begin{macrocode} -\RequirePackage{xcolor} -% \end{macrocode} -% -% 图形支持宏包。 -% \begin{macrocode} -\RequirePackage{graphicx} -% \end{macrocode} -% -% 表格支持宏包。 -% \begin{macrocode} -\RequirePackage{array} -\RequirePackage{booktabs} -\RequirePackage{longtable} -% \end{macrocode} -% -% 题注支持宏包。 -% \begin{macrocode} -\RequirePackage{caption} -\RequirePackage[list=off]{bicaption} -\RequirePackage{subcaption} -% \end{macrocode} -% -% 参考文献支持宏包。 -% \begin{macrocode} -\RequirePackage[backend=biber,style=\sjtu@bibstyle]{biblatex} -% \end{macrocode} -% -% 使用 \pkg{tocloft} 设置目录格式。 -% \begin{macrocode} -\RequirePackage[titles]{tocloft} -% \end{macrocode} -% -% \pkg{enumitem} 更好的列表环境。 -% \begin{macrocode} -\RequirePackage[inline]{enumitem} -% \end{macrocode} -% -% 脚注支持宏包。 -% \begin{macrocode} -\RequirePackage[perpage, bottom]{footmisc} -% \end{macrocode} -% -% \pkg{pdfpages} 便于我们插入扫描版的原创性声明和授权声明 PDF 文档。 -% \begin{macrocode} -\RequirePackage{pdfpages} -\includepdfset{fitpaper=true} -% \end{macrocode} -% -% \pkg{hyperref} 处理超链接。 -% \begin{macrocode} -\RequirePackage{hyperref} -% \end{macrocode} -% -% \subsection{信息录入} -% -% 定义命令用于录入信息。 -% \begin{macrocode} -\newcommand{\sjtu@def@term}[1]{% - \expandafter\gdef\csname #1\endcsname##1{% - \expandafter\gdef\csname sjtu@value@#1\endcsname{##1}} - \csname #1\endcsname{} - \define@key{sjtuvalue}{#1}{\csname #1\endcsname{##1}}} -% \end{macrocode} -% -% 论文中英文题目。 -% \begin{macrocode} -\sjtu@def@term{title} -\sjtu@def@term{entitle} -% \end{macrocode} -% -% 关键字。 -% \begin{macrocode} -\sjtu@def@term{keywords} -\sjtu@def@term{enkeywords} -% \end{macrocode} -% -% 作者、导师、副导师。 -% \begin{macrocode} -\sjtu@def@term{author} -\sjtu@def@term{supervisor} -\sjtu@def@term{assisupervisor} -\sjtu@def@term{enauthor} -\sjtu@def@term{ensupervisor} -\sjtu@def@term{enassisupervisor} -% \end{macrocode} -% -% 学号。 -% \begin{macrocode} -\sjtu@def@term{studentid} -% \end{macrocode} -% -% 申请学位中英文名称。 -% \begin{macrocode} -\sjtu@def@term{degree} -\sjtu@def@term{endegree} -% \end{macrocode} -% -% 院系中英文名称。 -% \begin{macrocode} -\sjtu@def@term{department} -\sjtu@def@term{endepartment} -% \end{macrocode} -% -% 专业中英文名称。 -% \begin{macrocode} -\sjtu@def@term{major} -\sjtu@def@term{enmajor} -% \end{macrocode} -% -% 课程中英文名称。 -% \begin{macrocode} -\sjtu@def@term{coursename} -\sjtu@def@term{encoursename} -% \end{macrocode} -% -% 资助基金名称。 -% \begin{macrocode} -\sjtu@def@term{fund} -\sjtu@def@term{enfund} -% \end{macrocode} -% -% 答辩日期。 -% \begin{macrocode} -\sjtu@def@term{date} -\sjtu@def@term{endate} -\NewDocumentCommand\sjtuSetInfo{}{\setkeys{sjtuvalue}} -% \end{macrocode} -% -% 定义一些文字常量。 -% \begin{macrocode} -\newcommand{\sjtu@def@label}[2]{% - \expandafter\gdef\csname sjtu@label@#1\endcsname{#2} - \define@key{sjtulabel}{#1}{% - \expandafter\gdef\csname sjtu@label@#1\endcsname{##1}}} -\sjtu@def@label{schoolChi}{上海交通大学} -\sjtu@def@label{schoolEng}{Shanghai Jiao Tong University} -% -%<*bachelor> -\ifsjtu@degree@course - \sjtu@def@label{degreetypeChi}{} - \sjtu@def@label{degreetypeEng}{} -\else - \sjtu@def@label{degreetypeChi}{学士} - \sjtu@def@label{degreetypeEng}{Bachelor} -\fi -\sjtu@def@label{authorChi}{学生姓名} -\sjtu@def@label{studentidChi}{学生学号} -\sjtu@def@label{supervisorChi}{指导教师} -\sjtu@def@label{coursenameChi}{课程名称} -\sjtu@def@label{majorChi}{专业} -\sjtu@def@label{departmentChi}{学院(系)} -\ifsjtu@degree@course - \sjtu@def@label{thesiscat}{课程论文} - \def\sjtu@label@thesistype{\sjtu@label@thesiscat} - \sjtu@def@label{subjectChi}{\sjtu@label@thesiscat} - \sjtu@def@label{subjectEng}{Course Paper} -\else - \sjtu@def@label{thesiscat}{学位论文} - \def\sjtu@label@thesistype{毕业设计(论文)} - \sjtu@def@label{subjectChi}{\sjtu@label@degreetypeChi\sjtu@label@thesiscat} - \sjtu@def@label{subjectEng}{Thesis of \sjtu@label@degreetypeEng} -\fi -\sjtu@def@label{bigabstract}{英文大摘要} -% -%<*graduate> -\ifsjtu@degree@doctor - \sjtu@def@label{degreetypeChi}{博士} - \sjtu@def@label{degreetypeEng}{Doctor} -\else - \sjtu@def@label{degreetypeChi}{硕士} - \sjtu@def@label{degreetypeEng}{Master} -\fi -\sjtu@def@label{authorChi}{\sjtu@label@degreetypeChi 研究生} -\sjtu@def@label{authorEng}{Candidate} -\sjtu@def@label{studentidChi}{学号} -\sjtu@def@label{studentidEng}{Student ID} -\sjtu@def@label{supervisorChi}{导师} -\sjtu@def@label{supervisorEng}{Supervisor} -\sjtu@def@label{assisupervisorChi}{副导师} -\sjtu@def@label{assisupervisorEng}{Assistant Supervisor} -\sjtu@def@label{degreeChi}{申请学位} -\sjtu@def@label{degreeEng}{Academic Degree Applied for} -\sjtu@def@label{majorChi}{学科} -\sjtu@def@label{majorEng}{Speciality} -\sjtu@def@label{departmentChi}{所在单位} -\sjtu@def@label{departmentEng}{Affiliation} -\sjtu@def@label{defenddateChi}{答辩日期} -\sjtu@def@label{defenddateEng}{Date of Defence} -\sjtu@def@label{conferringChi}{授予学位单位} -\sjtu@def@label{conferringEng}{Degree-Conferring-Institution} -\sjtu@def@label{fundChi}{资助基金} -\sjtu@def@label{fundEng}{Funded by} -\sjtu@def@label{thesiscat}{学位论文} -\def\sjtu@label@thesistype{\sjtu@label@thesiscat} -\sjtu@def@label{subjectChi}{% - \sjtu@label@schoolChi\sjtu@label@degreetypeChi\sjtu@label@thesiscat -} -\sjtu@def@label{subjectEng}{% - Dissertation Submitted to \sjtu@label@schoolEng \\% - for the Degree of \sjtu@label@degreetypeEng -} -% -%<*class> -\sjtu@def@label{originalityChi}{原创性声明} -\sjtu@def@label{originalityEng}{Declaration of Originality} -\sjtu@def@label{authorizationChi}{版权使用授权书} -\sjtu@def@label{authorizationEng}{Declaration of Authorization} -\sjtu@def@label{origtitle}{\sjtu@label@thesistype\sjtu@label@originalityChi} -\sjtu@def@label{authtitle}{\sjtu@label@thesistype\sjtu@label@authorizationChi} -\sjtu@def@label{origbody}{% - 本人郑重声明:所呈交的\sjtu@label@thesistype ,是本人在导师的指导下, - 独立进行研究工作所取得的成果。除文中已经注明引用的内容外,本论文不包含 - 任何其他个人或集体已经发表或撰写过的作品成果。对本文的研究做出重要贡献 - 的个人和集体,均已在文中以明确方式标明。本人完全意识到本声明的法律结果 - 由本人承担。} -\sjtu@def@label{authbody}{% - 本\sjtu@label@thesistype 作者 - 完全了解学校有关保留、使用\sjtu@label@thesistype 的规定,同意学校保留 - 并向国家有关部门或机构送交论文的复印件和电子版,允许论文被查阅和借阅。 - 本人授权\sjtu@label@schoolChi 可以将本\sjtu@label@thesistype 的全部或 - 部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描等复制手段保存 - 和汇编本\sjtu@label@thesistype 。} -\sjtu@def@label{abstractChi}{摘\quad 要} -\sjtu@def@label{abstractEng}{Abstract} -\sjtu@def@label{keywordsChi}{关键词:} -\sjtu@def@label{keywordsEng}{Key words:~} -\ifsjtu@language@english - \sjtu@def@label{titlepage}{Title Page} - \def\sjtu@label@originality{\sjtu@label@originalityEng} - \def\sjtu@label@authorization{\sjtu@label@authorizationEng} - \def\sjtu@label@abstract{\sjtu@label@abstractEng} - \sjtu@def@label{contents}{Contents} - \sjtu@def@label{figure}{Figure} - \sjtu@def@label{listfigure}{List of Figures} - \sjtu@def@label{table}{Table} - \sjtu@def@label{listtable}{List of Tables} - \sjtu@def@label{algorithm}{Algorithm} - \sjtu@def@label{listalgorithm}{List of Algorithms} - \sjtu@def@label{nomenclature}{Nomenclature} - \sjtu@def@label{summary}{Summary} - \sjtu@def@label{acknowledgements}{Acknowledgements} - \sjtu@def@label{publications}{Publications} - \sjtu@def@label{patents}{Patents} - \sjtu@def@label{projects}{Projects} - \sjtu@def@label{resume}{Resume} -\else - \sjtu@def@label{titlepage}{扉页} - \def\sjtu@label@originality{\sjtu@label@originalityChi} - \def\sjtu@label@authorization{\sjtu@label@authorizationChi} - \def\sjtu@label@abstract{\sjtu@label@abstractChi} - \sjtu@def@label{contents}{目\quad 录} - \sjtu@def@label{figure}{图} - \sjtu@def@label{listfigure}{插图索引} - \sjtu@def@label{table}{表} - \sjtu@def@label{listtable}{表格索引} - \sjtu@def@label{algorithm}{算法} - \sjtu@def@label{listalgorithm}{算法索引} - \sjtu@def@label{nomenclature}{主要符号对照表} - \sjtu@def@label{summary}{全文总结} - \sjtu@def@label{acknowledgements}{致\quad 谢} - \sjtu@def@label{publications}% - {攻读\sjtu@label@degreetypeChi 学位期间已发表或录用的论文} - \sjtu@def@label{patents}% - {攻读\sjtu@label@degreetypeChi 学位期间申请的专利} - \sjtu@def@label{projects}% - {攻读\sjtu@label@degreetypeChi 学位期间参与的项目} - \sjtu@def@label{resume}{简\quad 历} -\fi -\NewDocumentCommand\sjtuSetLabel{}{\setkeys{sjtulabel}} -\ctexset{% - contentsname = \sjtu@label@contents, - listfigurename = \sjtu@label@listfigure, - listtablename = \sjtu@label@listtable} -% \end{macrocode} -% -% \subsection{西文字体} -% -% 使用 \pkg{fontspec} 配置西文字体。 -% -% \cs{IfFontExistsTF} 是 \pkg{fontspec} v2.5c (2017/01/20) 才提供的;而 XITS 字 -% 体于 v1.109 (2018/09/28) 更改了字体的文件名。这里做一些兼容性设置。 -% \begin{macrocode} -\newif\ifsjtu@xitsnew -\@ifpackagelater{fontspec}{2017/01/20}{ - \IfFontExistsTF{XITSMath-Regular.otf}{ - \sjtu@xitsnewtrue - }{} -}{} -% \end{macrocode} -% -% 正文字体设置为 XITS,小型大写使用 TeX Gyre Termes 补充。 -% \begin{macrocode} -\ifsjtu@setlatinfont@main - \ifsjtu@xitsnew - \setmainfont{XITS}[ - Extension = .otf, - UprightFont = *-Regular, - BoldFont = *-Bold, - ItalicFont = *-Italic, - BoldItalicFont = *-BoldItalic, - UprightFeatures = { SmallCapsFont = texgyretermes-regular }, - BoldFeatures = { SmallCapsFont = texgyretermes-bold }, - ItalicFeatures = { SmallCapsFont = texgyretermes-italic }, - BoldItalicFeatures = { SmallCapsFont = texgyretermes-bolditalic }, - SmallCapsFeatures = { Letters = SmallCaps } - ] - \else - \setmainfont{xits}[ - Extension = .otf, - UprightFont = *-regular, - BoldFont = *-bold, - ItalicFont = *-italic, - BoldItalicFont = *-bolditalic, - UprightFeatures = { SmallCapsFont = texgyretermes-regular }, - BoldFeatures = { SmallCapsFont = texgyretermes-bold }, - ItalicFeatures = { SmallCapsFont = texgyretermes-italic }, - BoldItalicFeatures = { SmallCapsFont = texgyretermes-bolditalic }, - SmallCapsFeatures = { Letters = SmallCaps } - ] - \fi - \RequirePackage[opentype,scaled=.9]{sourcesanspro} - \RequirePackage[opentype,scaled=.9]{sourcecodepro} -\fi -% \end{macrocode} -% -% 使用 \pkg{unicode-math} 配置数学字体。 -% \begin{macrocode} -\ifsjtu@setlatinfont@math - \ifsjtu@xitsnew - \setmathfont{XITSMath-Regular}[ - Extension = .otf, - BoldFont = XITSMath-Bold, - StylisticSet = 8 - ] - \setmathfont{XITSMath-Regular.otf}[range={cal,bfcal},StylisticSet=1] - \else - \setmathfont{xits-math}[ - Extension = .otf, - BoldFont = *bold, - StylisticSet = 8 - ] - \setmathfont{xits-math.otf}[range={cal,bfcal},StylisticSet=1] - \fi -\fi -% -% \end{macrocode} -% -% \subsection{页面设置} -% -% 设置纸张、页边距。 -% \begin{macrocode} -%<*(bachelor|graduate)> -\geometry{% - paper = a4paper, -%<*bachelor> - vmargin = {84bp, 72bp}, - hmargin = 90bp, - headheight = 60bp, - headsep = 12bp, -% -%<*graduate> - top = 3.5cm, - bottom = 4.0cm, - left = 3.3cm, - right = 2.8cm, - headheight = 1.0cm, - headsep = 0.5cm, -% -} -% \end{macrocode} -% -% 设置页眉页脚。 -% \begin{macrocode} -%<*bachelor> -\ifsjtu@language@english - \def\sjtu@titlemark{\sjtu@value@entitle} - \newcommand{\sjtu@fancyhead}{% - \parbox[b]{0.75\textwidth}{% - \raggedleft\nouppercase{\footnotesize\heiti\sjtu@titlemark}}} - \newcommand{\sjtu@fancyfoot}[2]{% - \small --~~Page~~{\bfseries{#1}}~~of~~{\bfseries{#2}}~~--} -\else - \def\sjtu@titlemark{\sjtu@value@title} - \newcommand{\sjtu@fancyhead}{% - \parbox[b]{0.75\textwidth}{% - \raggedleft\nouppercase{\small\heiti\sjtu@titlemark}}} - \newcommand{\sjtu@fancyfoot}[2]{% - \small 第~{\bfseries{#1}}~页\,共~{\bfseries{#2}}~页} -\fi -\fancypagestyle{sjtu@front}{% - \fancyhf{} - \fancyhead[L]{\includegraphics{sjtu-logo.pdf}} - \fancyhead[R]{\sjtu@fancyhead} - \fancyfoot[C]{\sjtu@fancyfoot{\thepage}{\lastpageref{pagesLTS.Roman}}} -} -% -%<*graduate> -\newcommand{\sjtu@fancyfoot}[2]{ - \ifsjtu@review\relax\else - \ifx#2\@empty\else - \zihao{-5}{\bfseries #1}\\{#2} - \fi - \fi -} -\fancypagestyle{sjtu@title}{% - \fancyhf{} - \fancyfoot[C]{\sjtu@fancyfoot{\sjtu@label@fundChi}{\sjtu@value@fund}} - \renewcommand{\headrulewidth}{0pt} - \renewcommand{\footrulewidth}{0pt} -} -\fancypagestyle{sjtu@entitle}{% - \fancyhf{} - \fancyfoot[C]{\sjtu@fancyfoot{\sjtu@label@fundEng}{\sjtu@value@enfund}} - \renewcommand{\headrulewidth}{0pt} - \renewcommand{\footrulewidth}{0pt} -} -% -\fancypagestyle{sjtu@plain}{% - \fancyhf{} -%<*bachelor> - \fancyhead[L]{\includegraphics{sjtu-logo.pdf}} - \fancyhead[R]{\sjtu@fancyhead} - \fancyfoot[C]{\sjtu@fancyfoot{\thepage}{\lastpageref{pagesLTS.arabic}}} -% -%<*graduate> - \fancyhead[C]{\zihao{-5}\sjtu@label@subjectChi} - \fancyfoot[C]{\small ---~{\bfseries\thepage}~---} - \renewcommand{\headrule}{% - \hrule\@height2.25\p@\@width\headwidth - \vskip 0.75\p@ - \hrule\@height0.75\p@\@width\headwidth - \vskip -2.75\p@ - } -% -} -%<*bachelor> -\fancypagestyle{sjtu@biglast}{% - \fancyhf{} - \fancyhead[L]{\includegraphics{sjtu-logo.pdf}} - \fancyhead[R]{\sjtu@fancyhead} - \fancyfoot[C]{\sjtu@fancyfoot{\theCurrentPageLocal}% - {\lastpageref{pagesLTS.roman.local}}} -} -% -% -% \end{macrocode} -% -% \subsection{主文档格式} -% -% \subsubsection{Three matters} -% -% \begin{macro}{\cleardoublepage} -% 空白页清空页眉页脚。 -% \begin{macrocode} -%<*class> -\patchcmd\cleardoublepage% - {\newpage}{\thispagestyle{empty}\newpage} - {}{} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\chapter} -% 每章第一页默认会设置特殊的 pagestyle, 我们将其清除。 -% \begin{macrocode} -\patchcmd\chapter% - {\thispagestyle{\CTEX@chapter@pagestyle}}{} - {}{} -% \end{macrocode} -% \end{macro} -% -% 设置文档开始时初始的页码与页眉页脚风格。 -% \begin{macrocode} -\AtBeginDocument{% - \pagenumbering{Alph} - \pagestyle{empty}} -% -% \end{macrocode} -% -% \begin{macro}{\frontmatter} -% \begin{macro}{\mainmatter} -% \begin{macro}{\backmatter} -% 前言的页码设置为大写罗马数字,同时设置前言与正文的页眉页脚风格。 -% \begin{macrocode} -%<*(bachelor|graduate)> -\renewcommand{\frontmatter}{% - \cleardoublepage - \@mainmatterfalse - \pagenumbering{Roman} -% \pagestyle{sjtu@front} -% \pagestyle{sjtu@plain} -} -\renewcommand{\mainmatter}{% - \cleardoublepage - \@mainmattertrue - \sjtu@setfloatfonttrue - \pagenumbering{arabic} - \pagestyle{sjtu@plain} -} -\renewcommand{\backmatter}{% - \cleardoublepage - \@mainmatterfalse -} -% -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \subsubsection{章节标题} -% 各级标题格式设置。 -% \begin{macrocode} -%<*class> -\ctexset{% - chapter={% - format = \zihao{3}\bfseries\heiti\centering, - nameformat = {}, - titleformat = {}, - aftername = \quad, - afterindent = true, - beforeskip = 1ex, - afterskip = 2ex - }, - section={% - format = \zihao{4}\bfseries\heiti, - afterindent = true, - afterskip = 1ex \@plus .2ex - }, - subsection={% - format = \zihao{-4}\bfseries\heiti, - afterindent = true, - afterskip = 1ex \@plus .2ex - }, - subsubsection={% - format = \zihao{-4}\normalfont, - afterindent = true, - afterskip = 1ex \@plus .2ex - }, - paragraph/afterindent = true, - subparagraph/afterindent = true} -% -% \end{macrocode} -% -% 本科与研究生论文三级标题格式不同。 -% \begin{macrocode} -%<*bachelor> -\ctexset{% - subsection/format = \zihao{-4}\normalfont, -} -% -% \end{macrocode} -% -% \subsubsection{段落} -% -% 全文首行缩进 2 字符,标点符号用全角。 -% \begin{macrocode} -%<*class> -\ctexset{% - punct = quanjiao, - space = auto, - autoindent = true} -% \end{macrocode} -% -% 使用松散的断行模式。 -% \begin{macrocode} -\AtEndOfClass{\sloppy} -% \end{macrocode} -% -% 利用 \pkg{enumitem} 命令调整默认列表环境间的距离,以符合中文习惯。 -% \begin{macrocode} -\setlist{nosep} -\setlist*{leftmargin=*} -\setlist[1]{labelindent=\parindent} -% \end{macrocode} -% -% \subsubsection{目录} -% -% 章节编号深度最多 4 层,即: x.x.x.x,对应的命令和层序号分别是: -% \cs{chapter}(0), \cs{section}(1), \cs{subsection}(2), \cs{subsubsection}(3)。 -% \begin{macrocode} -\setcounter{secnumdepth}{3} -\setcounter{tocdepth}{2} -% \end{macrocode} -% -% \begin{macro}{\tableofcontents} -% 目录生成命令,添加 PDF 标签。 -% \begin{macrocode} -\renewcommand{\tableofcontents}{% - \cleardoublepage% - \pdfbookmark[0]{\contentsname}{toc}% - \chapter*{\contentsname}% - \@mkboth{\contentsname}{\contentsname}% - \@starttoc{toc} -} -\renewcommand{\listoffigures}{% - \cleardoublepage% - \pdfbookmark[0]{\listfigurename}{lof}% - \chapter*{\listfigurename}% - \@mkboth{\listfigurename}{\listfigurename}% - \@starttoc{lof} -} -\renewcommand{\listoftables}{% - \cleardoublepage% - \pdfbookmark[0]{\listtablename}{lot}% - \chapter*{\listtablename}% - \@mkboth{\listtablename}{\listtablename}% - \@starttoc{lot} -} -% -% \end{macrocode} -% \end{macro} -% -% 本科与研究生论文设置不同的目录格式。 -% \begin{macrocode} -%<*bachelor> -\renewcommand{\cftchapfont}{\normalfont} -\renewcommand{\cftchapleader}{\normalfont\cftdotfill{\cftdotsep}} -\renewcommand{\cftchappagefont}{\normalfont} -% -%<*graduate> -\renewcommand{\cftchapfont}{\bfseries\heiti} -\renewcommand{\cftchapleader}{\normalfont\cftdotfill{\cftdotsep}} -% -% \end{macrocode} -% -% 图表索引前加下“图”,“表”关键词。 -% \begin{macrocode} -%<*class> -\renewcommand{\cftfigpresnum}{\sjtu@label@figure~} -\renewcommand{\cfttabpresnum}{\sjtu@label@table~} -\AtEndPreamble{% - \newlength{\sjtu@cftfignumwidth@tmp} - \settowidth{\sjtu@cftfignumwidth@tmp}{\cftfigpresnum} - \addtolength{\cftfignumwidth}{\sjtu@cftfignumwidth@tmp} - \newlength{\sjtu@cfttabnumwidth@tmp} - \settowidth{\sjtu@cfttabnumwidth@tmp}{\cfttabpresnum} - \addtolength{\cfttabnumwidth}{\sjtu@cfttabnumwidth@tmp} -} -% \end{macrocode} -% -% \subsubsection{浮动对象以及表格} -% -% 下面这组命令使浮动对象的缺省值稍微宽松一点,从而防止幅度对象占据过多的文本页 -% 面,也可以防止在很大空白的浮动页上放置很小的图形。 -% \begin{macrocode} -\renewcommand{\textfraction}{0.15} -\renewcommand{\topfraction}{0.85} -\renewcommand{\bottomfraction}{0.65} -\renewcommand{\floatpagefraction}{0.60} -% \end{macrocode} -% -% 定义公式、图、表的编号为“3-1”的形式,即分隔符由“.”变为“-”。 -% \begin{macrocode} -\AtBeginDocument{% - \renewcommand{\theequation}{\thechapter--\arabic{equation}} - \renewcommand{\thefigure}{\thechapter--\arabic{figure}} - \renewcommand{\p@subfigure}{\thefigure} - \renewcommand{\thetable}{\thechapter--\arabic{table}} -} -% \end{macrocode} -% -% 设置浮动体内的默认字号。 -% \begin{macrocode} -\newif\ifsjtu@setfloatfont -\renewcommand{\@floatboxreset}{% - \reset@font - \ifsjtu@setfloatfont - \zihao{5} - \else - \normalsize - \fi - \@setminipage -} -\BeforeBeginEnvironment{longtable} - {\begingroup\ifsjtu@setfloatfont\zihao{5}\fi} -\AfterEndEnvironment{longtable} - {\endgroup} -\NewDocumentCommand{\sjtuSetFloatFontOn}{}{\sjtu@setfloatfonttrue} -\NewDocumentCommand{\sjtuSetFloatFontOff}{}{\sjtu@setfloatfontfalse} -% \end{macrocode} -% -% 设置双语题注。 -% \begin{macrocode} -\DeclareCaptionFont{sjtucaptionfont}{\zihao{5}\kaishu} -\DeclareCaptionFont{sjtusubcaptionfont}{\zihao{5}\normalfont} -\captionsetup{% - format = plain, - labelformat = simple, - labelsep = space, - justification = centering, - font = sjtucaptionfont -} -\captionsetup[sub]{% - format = hang, - labelformat = brace, - justification = justified, - font = sjtusubcaptionfont -} -\DeclareCaptionOption{bi-first}[]{% - \def\tablename{\sjtu@label@table} - \def\figurename{\sjtu@label@figure}} -\DeclareCaptionOption{bi-second}[]{% - \def\tablename{Table} - \def\figurename{Figure}} -\captionsetup[bi-first]{bi-first} -\captionsetup[bi-second]{bi-second} -% \end{macrocode} -% -% \subsubsection{数学相关} -% -% 根据中文的数学排印习惯进行调整: -% \begin{macrocode} -\ifsjtu@mathstyle@GB -% \end{macrocode} -% -% \begin{macro}{\ldots} -% 省略号一律居中,所以 \cs{ldots} 不再居于底部。 -% \begin{macrocode} - \let\mathellipsis\cdots -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\Re} -% \begin{macro}{\Im} -% 实部、虚部操作符使用罗马体 $\mathrm{Re}$、$\mathrm{Im}$ 而不是 fraktur 体 -% $\Re$、$\Im$。 -% \begin{macrocode} - \AtBeginDocument{% - \renewcommand{\Re}{\operatorname{Re}}% - \renewcommand{\Im}{\operatorname{Im}}% - } -\fi -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\upe} -% \begin{macro}{\upi} -% \begin{macro}{\upj} -% \begin{macro}{\dif} -% 提供一些方便的命令: -% \begin{macrocode} -\newcommand\upe{\mathrm{e}} -\newcommand\upi{\mathrm{i}} -\newcommand\upj{\mathrm{j}} -\newcommand\dif{\mathop{}\!\mathrm{d}} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \subsubsection{声明} -% -% 支持扫描文件替换。 -% \begin{macrocode} -\newcommand{\sjtu@square}{% - \begingroup\CJKfamily+{zhsong}\symbol{"25A1}\endgroup -} -\newcommand{\sjtu@authconf}{% - \par\hspace{7em}% - {\heiti 保\quad 密}~\sjtu@square,在 \uline{\hspace{3em}} - 年解密后适用本授权书。\par - 本\sjtu@label@thesiscat 属于 - \par\hspace{7em}% - {\heiti 不保密}~\sjtu@square。 - \vskip 1ex - (请在以上方框内打“$\checkmark$”) -} -\newcommand{\sjtu@signbox}[1]{% - \parbox{.45\textwidth}{% - #1 签名: \vskip 4em% - 日期: \hspace{\stretch{3}} 年% - \hspace{\stretch{2}} 月 \hspace{\stretch{2}} 日% - } -} -\NewDocumentCommand{\makeDeclareOriginality}{o}{% - \ifsjtu@review\relax\else - \cleardoublepage - \pdfbookmark[0]{\sjtu@label@originality}{origtitle} - \IfNoValueTF{#1}{% - \thispagestyle{empty} - \chapter*{\zihao{-2}\sjtu@label@schoolChi \\% - \sjtu@label@origtitle} - \begingroup - \zihao{4} - \sjtu@label@origbody - \vskip 16ex - \noindent - \begin{minipage}{\textwidth} - \hfill - \sjtu@signbox{\sjtu@label@thesiscat 作者} - \end{minipage} - \endgroup - } - {\includepdf[pagecommand={\thispagestyle{empty}}]{#1}} - \cleardoublepage - \fi -} -\NewDocumentCommand{\makeDeclareAuthorization}{o}{% - \ifsjtu@review\relax\else - \cleardoublepage - \pdfbookmark[0]{\sjtu@label@authorization}{authtitle} - \IfNoValueTF{#1}{% - \thispagestyle{empty} - \chapter*{\zihao{-2}\sjtu@label@schoolChi \\% - \sjtu@label@authtitle} - \begingroup - \zihao{4} - \sjtu@label@authbody - \vskip 1ex - \sjtu@authconf - \vskip 16ex - \noindent - \begin{minipage}{\textwidth} - \sjtu@signbox{\sjtu@label@thesiscat 作者} - \hfill - \sjtu@signbox{指导教师} - \end{minipage} - \endgroup - } - {\includepdf[pagecommand={\thispagestyle{empty}}]{#1}} - \cleardoublepage - \fi -} -% -% \end{macrocode} -% -% \subsubsection{摘要} -% -% 定义摘要环境,本科与研究生论文的摘要样式要求略有不同。 -% \begin{macrocode} -%<*(bachelor|graduate)> -\NewDocumentEnvironment{abstract}{}{% - \cleardoublepage - \pdfbookmark[0]{\sjtu@label@abstract}{abstract} - \chapter*{% - \sjtu@value@title \vskip 2ex - \begingroup -% \zihao{4} - \sjtu@label@abstractChi - \endgroup - } - \@mkboth{\sjtu@label@abstractChi}% - {\sjtu@label@abstractChi}% -% \zihao{4} -}{% - \vskip 3ex \noindent - \begingroup -% \zihao{-4} - \heiti\sjtu@label@keywordsChi - \endgroup - \begingroup -% \zihao{5} - \sjtu@value@keywords - \endgroup -} -% \end{macrocode} -% -% 英文摘要。 -% \begin{macrocode} -\NewDocumentEnvironment{enabstract}{}{% - \cleardoublepage - \chapter*{% - \MakeUppercase\sjtu@value@entitle \vskip 2ex - \begingroup -% \zihao{4} - \MakeUppercase\sjtu@label@abstractEng - \endgroup - } - \@mkboth{\sjtu@label@abstractEng}% - {\sjtu@label@abstractEng}% -% \zihao{4} -}{% - \vskip 3ex \noindent - \begingroup -% \zihao{-4}\bfseries -% \bfseries\MakeUppercase - \sjtu@label@keywordsEng - \endgroup - \begingroup -% \zihao{5} - \sjtu@value@enkeywords - \endgroup -} -% \end{macrocode} -% -% 本科论文英文大摘要。 -% \begin{macrocode} -\newcommand{\sjtu@bigabstract}[1]{\long\gdef\sjtu@bigabstract@body{#1}} -\NewDocumentEnvironment{bigabstract}{}{% - \Collect@Body\sjtu@bigabstract -}{% -%<*bachelor> - \ifsjtu@degree@course\relax\else - \ifsjtu@language@english\relax\else - \AtEndDocument{% - \cleardoublepage - \pagenumbering{roman} - \pagestyle{sjtu@biglast} - \pdfbookmark[0]{\sjtu@label@bigabstract}{bigabstract}% - \chapter*{\MakeUppercase\sjtu@value@entitle} - \@mkboth{\sjtu@label@bigabstract}% - {\sjtu@label@bigabstract}% - \sjtu@bigabstract@body - } - \fi - \fi -% -% \relax -} -% -% \end{macrocode} -% -% \subsubsection{主要符号对照表} -% -% 使用 \pkg{longtable} 实现符号对照表。 -% \begin{macrocode} -%<*class> -\NewDocumentEnvironment{nomenclature}{m}{% - \cleardoublepage - \pdfbookmark[0]{\sjtu@label@nomenclature}{nomenclature} - \chapter*{\sjtu@label@nomenclature} - \@mkboth{\sjtu@label@nomenclature}% - {\sjtu@label@nomenclature}% - \begin{longtable}{#1} -}{\end{longtable}} -% \end{macrocode} -% -% \subsubsection{全文总结} -% -% \begin{macrocode} -\NewDocumentEnvironment{summary}{}{% - \cleardoublepage - \chapter*{\sjtu@label@summary} - \@mkboth{\sjtu@label@summary}% - {\sjtu@label@summary}% - \addcontentsline{toc}{chapter}{\sjtu@label@summary}% -}{} -% \end{macrocode} -% -% \subsubsection{致谢} -% -% 定义致谢环境,盲审模式下隐藏致谢。 -% \begin{macrocode} -\newcommand{\sjtu@acknowledgements}[1]{\long\gdef\sjtu@acknowledgements@body{#1}} -\NewDocumentEnvironment{acknowledgements}{}{% - \Collect@Body\sjtu@acknowledgements -}{% - \ifsjtu@review\relax\else - \cleardoublepage - \chapter*{\sjtu@label@acknowledgements} - \@mkboth{\sjtu@label@acknowledgements}% - {\sjtu@label@acknowledgements}% - \addcontentsline{toc}{chapter}{\sjtu@label@acknowledgements}% - \sjtu@acknowledgements@body - \fi -} -% \end{macrocode} -% -% \subsubsection{附录} -% -% 定义附录使用的列表环境,使用和参考文献列表相同的样式。 -% \begin{macrocode} -\newenvironment{sjtu@bibliolist}[2]{% - \cleardoublepage - \chapter{#2} - \@mkboth{#2}{#2}% - \list{\@biblabel{\@arabic\c@enumiv}}% - {\settowidth\labelwidth{\@biblabel{#1}}% - \leftmargin\labelwidth - \advance\leftmargin\labelsep - \@openbib@code - \usecounter{enumiv}% - \let\p@enumiv\@empty - \renewcommand\theenumiv{\@arabic\c@enumiv}}% - \sloppy - \clubpenalty4000 - \@clubpenalty \clubpenalty - \widowpenalty4000% - \sfcode`\.\@m -}{% - \def\@noitemerr - {\@latex@warning{Empty `bibliolist' environment}}% - \endlist -} -% \end{macrocode} -% -% 分别定义论文、专利和项目三个附录环境。 -% \begin{macrocode} -\newcommand{\sjtu@publications}[1]{\long\gdef\sjtu@publications@body{#1}} -\NewDocumentEnvironment{publications}{O{99}}{% - \Collect@Body\sjtu@publications -}{% - \ifsjtu@review\relax\else - \begin{sjtu@bibliolist}{#1}{\sjtu@label@publications} - \sjtu@publications@body - \end{sjtu@bibliolist} - \fi -} -\newcommand{\sjtu@@publications}[1]{\long\gdef\sjtu@@publications@body{#1}} -\NewDocumentEnvironment{publications*}{O{99}}{% - \Collect@Body\sjtu@@publications -}{% - \ifsjtu@review - \begin{sjtu@bibliolist}{#1}{\sjtu@label@publications} - \sjtu@@publications@body - \end{sjtu@bibliolist} - \fi -} -\newcommand{\sjtu@projects}[1]{\long\gdef\sjtu@projects@body{#1}} -\NewDocumentEnvironment{projects}{O{99}}{% - \Collect@Body\sjtu@projects -}{% - \ifsjtu@review\relax\else - \begin{sjtu@bibliolist}{#1}{\sjtu@label@projects} - \sjtu@projects@body - \end{sjtu@bibliolist} - \fi -} -\newcommand{\sjtu@@projects}[1]{\long\gdef\sjtu@@projects@body{#1}} -\NewDocumentEnvironment{projects*}{O{99}}{% - \Collect@Body\sjtu@@projects -}{% - \ifsjtu@review - \begin{sjtu@bibliolist}{#1}{\sjtu@label@projects} - \sjtu@@projects@body - \end{sjtu@bibliolist} - \fi -} -\newcommand{\sjtu@patents}[1]{\long\gdef\sjtu@patents@body{#1}} -\NewDocumentEnvironment{patents}{O{99}}{% - \Collect@Body\sjtu@patents -}{% - \ifsjtu@review\relax\else - \begin{sjtu@bibliolist}{#1}{\sjtu@label@patents} - \sjtu@patents@body - \end{sjtu@bibliolist} - \fi -} -\newcommand{\sjtu@@patents}[1]{\long\gdef\sjtu@@patents@body{#1}} -\NewDocumentEnvironment{patents*}{O{99}}{% - \Collect@Body\sjtu@@patents -}{% - \ifsjtu@review - \begin{sjtu@bibliolist}{#1}{\sjtu@label@patents} - \sjtu@@patents@body - \end{sjtu@bibliolist} - \fi -} -% \end{macrocode} -% -% 定义简历环境。 -% \begin{macrocode} -\newcommand{\sjtu@resume}[1]{\long\gdef\sjtu@resume@body{#1}} -\NewDocumentEnvironment{resume}{}{% - \Collect@Body\sjtu@resume -}{% - \ifsjtu@review\relax\else - \cleardoublepage - \chapter{\sjtu@label@resume} - \@mkboth{\sjtu@label@resume}% - {\sjtu@label@resume}% - \sjtu@resume@body - \fi -} -% \end{macrocode} -% -% \subsubsection{盲审模式} -% -% 盲审模式下隐藏作者、导师姓名等信息。同时将论文信息写入 PDF 元数据。 -% \begin{macrocode} -\AtBeginDocument{ - \ifsjtu@review% - \sjtuSetInfo{% - author={}, - supervisor={}, - assisupervisor={}, - enauthor={}, - ensupervisor={}, - enassisupervisor={}, - studentid={}, - date={}, - endate={} - } - \fi - \hypersetup{% - pdftitle = \sjtu@value@title, - pdfauthor = \sjtu@value@author, - pdfsubject = \sjtu@label@subjectChi, - pdfkeywords = \sjtu@value@keywords, - pdfcreator = {LaTeX with SJTUThesis \version} - }% -} -% \end{macrocode} -% -% \begin{macro}{\encrypt} -% 定义盲审模式工具宏\cs{encrypt}: -% \begin{macrocode} -\NewDocumentCommand{\encrypt}{m O{***}}{% - \ifsjtu@review - {#2} - \else - {#1} - \fi -} -% \end{macrocode} -% \end{macro} -% -% \subsubsection{封面} -% -% 定义一个特殊的下划线命令供绘制本科论文封面时使用。 -% \begin{macrocode} -\newcommand{\sjtu@uline}[1]{% - \begingroup - \setbox0=\vbox{\strut #1\strut}% - \dimen0=0pt - \loop\ifdim\ht0>0pt - \dimen1=\dimexpr\ht0 - \baselineskip\relax - \setbox1=\vsplit0 to \ht\strutbox - \advance\dimen1 by -\ht0 - \noindent\raisebox{-\dimen0}[\ht\strutbox][\dp\strutbox]{\box1}% - \advance\dimen0 by \dimen1 - \vspace{-0.2ex}\hrule\vskip 0.2ex - \repeat - \endgroup -} -% -% \end{macrocode} -% -% 绘制封面 -% \begin{macrocode} -%<*(bachelor|graduate)> -\RenewDocumentCommand\maketitle{}{% - \pdfbookmark[0]{\sjtu@label@titlepage}{titlepage} - \sjtu@makechinesetitle% -% \sjtu@makeenglishtitle% -} -\newcommand{\sjtu@makechinesetitle}{% - \cleardoublepage -%<*bachelor> - \thispagestyle{empty} - \begin{center} - \kaishu - \vspace*{48bp} - \includegraphics{sjtu-name.pdf} - \vskip 28bp - {\fontsize{32}{32}\sjtu@label@subjectChi} - \vskip 16bp - {\zihao{-2}\MakeUppercase\sjtu@label@subjectEng} - \vskip 16bp - \includegraphics{sjtu-badge.pdf} - \vskip \stretch{2} - \begingroup - \zihao{2} - \begin{tabular}{r@{:}l} - 论文题目 & - \begin{minipage}[t]{280pt} - \zihao{-2} - \begin{center} - \sjtu@uline\sjtu@value@title - \end{center} - \end{minipage} - \end{tabular} - \endgroup - \vskip \stretch{1} - \begingroup - \zihao{3} - \def\arraystretch{1.1} - \begin{tabular} - {>{\begin{CJKfilltwosides}{4\ccwd}}r<{\end{CJKfilltwosides}}@{:}c} - \sjtu@label@authorChi & \sjtu@value@author \\ \cline{2-2} - \sjtu@label@studentidChi & \makebox[180pt]{\sjtu@value@studentid} \\ - \cline{2-2} - \ifsjtu@degree@course - \sjtu@label@coursenameChi & \sjtu@value@coursename \\ \cline{2-2} - \else - \sjtu@label@majorChi & \sjtu@value@major \\ \cline{2-2} - \fi - \sjtu@label@supervisorChi & \sjtu@value@supervisor \\ \cline{2-2} - \sjtu@label@departmentChi & \sjtu@value@department \\ \cline{2-2} - \end{tabular} - \endgroup - \vskip 40bp -% -%<*graduate> - \thispagestyle{sjtu@title} - \begin{center} - \vspace*{40bp} - {\zihao{-2}\sjtu@label@subjectChi} - \vskip \stretch{4} - {\zihao{2}\heiti\sjtu@value@title \vskip 1bp} - \vskip \stretch{5} - \begingroup - \zihao{4} - \def\tabcolsep{1bp} - \def\arraystretch{1.25} - \begin{tabular} - {>{\begin{CJKfilltwosides}[t]{6.5\ccwd}\heiti}r<{\end{CJKfilltwosides}} - @{:}l} - \sjtu@label@authorChi & \sjtu@value@author \\ - \sjtu@label@studentidChi & \sjtu@value@studentid \\ - \sjtu@label@supervisorChi & \sjtu@value@supervisor \\ - \ifx\sjtu@value@assisupervisor\@empty\else - \sjtu@label@assisupervisorChi & \sjtu@value@assisupervisor \\ - \fi - \sjtu@label@degreeChi & \sjtu@value@degree \\ - \sjtu@label@majorChi & \sjtu@value@major \\ - \sjtu@label@departmentChi & \sjtu@value@department \\ - \sjtu@label@defenddateChi & \sjtu@value@date \\ - \sjtu@label@conferringChi & \sjtu@label@schoolChi \\ - \end{tabular} - \endgroup - \vskip 26bp -% - \end{center} - \cleardoublepage -} -%<*graduate> -\newcommand{\sjtu@makeenglishtitle}{% - \cleardoublepage - \thispagestyle{sjtu@entitle} - \begin{center} - \vspace*{28bp} - {\zihao{-2}\sjtu@label@subjectEng \vskip 1bp} - \vskip \stretch{4} - {\zihao{2}\bfseries\MakeUppercase\sjtu@value@entitle \vskip 1bp} - \vskip \stretch{5} - \begingroup - \zihao{4} - \def\tabcolsep{1bp} - \def\arraystretch{1.3} - \begin{tabular} - {>{\bfseries}l<{:~}p{.45\textwidth}} - \sjtu@label@authorEng & \sjtu@value@enauthor \\ - \sjtu@label@studentidEng & \sjtu@value@studentid \\ - \sjtu@label@supervisorEng & \sjtu@value@ensupervisor \\ - \ifx\sjtu@value@enassisupervisor\@empty\else - \sjtu@label@assisupervisorEng & \sjtu@value@enassisupervisor \\ - \fi - \sjtu@label@degreeEng & \sjtu@value@endegree \\ - \sjtu@label@majorEng & \sjtu@value@enmajor \\ - \sjtu@label@departmentEng & \sjtu@value@endepartment \\ - \sjtu@label@defenddateEng & \sjtu@value@endate \\ - \sjtu@label@conferringEng & \sjtu@label@schoolEng \\ - \end{tabular} - \endgroup - \vskip 26bp - \end{center} - \cleardoublepage -} -% -% -% \end{macrocode} -% -% \subsection{文档部件} -% -% \subsubsection{超链接} -% -% \begin{macrocode} -%<*class> -\hypersetup{ - linktoc = all, - bookmarksnumbered = true, - bookmarksopen = true, - bookmarksopenlevel = 1, - unicode = true, - psdextra = true, - breaklinks = true, - plainpages = false, - hidelinks, -} -\pdfstringdefDisableCommands{% - \let\\\@empty - \let\quad\@empty - \let\hspace\@gobble -} -% \end{macrocode} -% -% 设置 url 样式,与上下文一致。 -% \begin{macrocode} -\urlstyle{same} -% \end{macrocode} -% -% 使用 \pkg{xurl} 的方法,增加 URL 可断行的位置。 -% \begin{macrocode} -\def\UrlBreaks{% - \do\/% - \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l% - \do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z% - \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L% - \do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z% - \do0\do1\do2\do3\do4\do5\do6\do7\do8\do9\do=\do/\do.\do:% - \do\*\do\-\do\~\do\'\do\"\do\-} -\Urlmuskip=0mu plus 0.1mu -% -% \end{macrocode} -% -% \subsection{其他宏包的设置} -% -% 这些宏包并非格式要求,但是为了方便同学们使用,在这里进行简单设置。 -% \begin{macrocode} -%<*class> -\newcommand{\sjtu@atendpackage}{\csname ctex_at_end_package:nn\endcsname} -% \end{macrocode} -% -% \subsubsection{\pkg{unicode-math} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{unicode-math}{ -% \end{macrocode} -% -% \begin{macro}{\bm} -% \begin{macro}{\boldsymbol} -% 兼容旧的粗体命令:\pkg{bm} 的 \cs{bm} 和 \pkg{amsmath} 的 \cs{boldsymbol}。 -% \begin{macrocode} - \newcommand{\bm}{\symbf} - \renewcommand{\boldsymbol}{\symbf} -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\square} -% 兼容 \pkg{amssymb} 中的命令。 -% \begin{macrocode} - \newcommand{\square}{\mdlgwhtsquare} -% \end{macrocode} -% \end{macro} -% -% 修复 \pkg{hyperref} 与 \pkg{unicode-math} 存在一些兼容性问题。 -% \begin{macrocode} - \@ifpackagelater{hyperref}{2019/04/27}{}{% - \g@addto@macro\psdmapshortnames{\let\mu\textmugreek}% - } -} -% \end{macrocode} -% -% \subsubsection{\pkg{threeparttable} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{threeparttable}{ - \appto\TPTnoteSettings{\footnotesize} -} -% \end{macrocode} -% -% \subsubsection{\pkg{siunitx} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{siunitx}{ - \sisetup{ - detect-all, - group-minimum-digits = 4, - separate-uncertainty = true, - inter-unit-product = \ensuremath{{}\cdot{}}, - } - \ifsjtu@language@chinese - \sisetup{ - list-final-separator = { 和 }, - list-pair-separator = { 和 }, - range-phrase = {~}, - } - \fi -} -% \end{macrocode} -% -% \subsubsection{\pkg{ntheorem} 宏包} -% -% \begin{macrocode} -\PassOptionsToPackage{amsmath,thmmarks,hyperref}{ntheorem} -\sjtu@atendpackage{ntheorem}{ - \ifsjtu@language@chinese - \def\sjtu@label@assertion{断言} - \def\sjtu@label@assumption{假设} - \def\sjtu@label@axiom{公理} - \def\sjtu@label@corollary{推论} - \def\sjtu@label@definition{定义} - \def\sjtu@label@example{例} - \def\sjtu@label@lemma{引理} - \def\sjtu@label@proof{证明} - \def\sjtu@label@proposition{命题} - \def\sjtu@label@remark{注} - \def\sjtu@label@theorem{定理} - \else - \def\sjtu@label@assertion{Assertion} - \def\sjtu@label@assumption{Assumption} - \def\sjtu@label@axiom{Axiom} - \def\sjtu@label@corollary{Corollary} - \def\sjtu@label@definition{Definition} - \def\sjtu@label@example{Example} - \def\sjtu@label@lemma{Lemma} - \def\sjtu@label@proof{Proof} - \def\sjtu@label@proposition{Proposition} - \def\sjtu@label@remark{Remark} - \def\sjtu@label@theorem{Theorem} - \fi - \theoremheaderfont{\bfseries\heiti} - \theorembodyfont{\normalfont} - \theoremseparator{\enskip} - \theoremsymbol{\ensuremath{\square}} - \newtheorem*{proof}{\sjtu@label@proof} - \theoremstyle{plain} - \theoremsymbol{} - \newtheorem{theorem} {\sjtu@label@theorem} [chapter] - \newtheorem{assertion} [theorem]{\sjtu@label@assertion} - \newtheorem{axiom} [theorem]{\sjtu@label@axiom} - \newtheorem{corollary} [theorem]{\sjtu@label@corollary} - \newtheorem{lemma} [theorem]{\sjtu@label@lemma} - \newtheorem{proposition}[theorem]{\sjtu@label@proposition} - \newtheorem{assumption} {\sjtu@label@assumption} [chapter] - \newtheorem{definition} {\sjtu@label@definition} [chapter] - \newtheorem{example} {\sjtu@label@example} [chapter] - \newtheorem*{remark} {\sjtu@label@remark} -} -% \end{macrocode} -% -% \subsubsection{\pkg{amsthm} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{amsthm}{ - \ifsjtu@language@chinese - \def\sjtu@label@assertion{断言} - \def\sjtu@label@assumption{假设} - \def\sjtu@label@axiom{公理} - \def\sjtu@label@corollary{推论} - \def\sjtu@label@definition{定义} - \def\sjtu@label@example{例} - \def\sjtu@label@lemma{引理} - \def\sjtu@label@proof{证明} - \def\sjtu@label@proposition{命题} - \def\sjtu@label@remark{注} - \def\sjtu@label@theorem{定理} - \else - \def\sjtu@label@assertion{Assertion} - \def\sjtu@label@assumption{Assumption} - \def\sjtu@label@axiom{Axiom} - \def\sjtu@label@corollary{Corollary} - \def\sjtu@label@definition{Definition} - \def\sjtu@label@example{Example} - \def\sjtu@label@lemma{Lemma} - \def\sjtu@label@proof{Proof} - \def\sjtu@label@proposition{Proposition} - \def\sjtu@label@remark{Remark} - \def\sjtu@label@theorem{Theorem} - \fi - \newtheoremstyle{sjtuplain} - {}{} - {\normalfont}{} - {\bfseries\heiti}{} - {\ccwd}{} - \theoremstyle{sjtuplain} - \newtheorem{theorem} {\sjtu@label@theorem} [chapter] - \newtheorem{assertion} [theorem]{\sjtu@label@assertion} - \newtheorem{axiom} [theorem]{\sjtu@label@axiom} - \newtheorem{corollary} [theorem]{\sjtu@label@corollary} - \newtheorem{lemma} [theorem]{\sjtu@label@lemma} - \newtheorem{proposition}[theorem]{\sjtu@label@proposition} - \newtheorem{assumption} {\sjtu@label@assumption} [chapter] - \newtheorem{definition} {\sjtu@label@definition} [chapter] - \newtheorem{example} {\sjtu@label@example} [chapter] - \newtheorem*{remark} {\sjtu@label@remark} - \renewcommand\proofname\sjtu@label@proof - \renewenvironment{proof}[1][\proofname]{\par - \pushQED{\qed}% - \normalfont \topsep6\p@\@plus6\p@\relax - \trivlist - \item\relax - {\bfseries\heiti #1~} - \hspace\labelsep\ignorespaces - }{% - \popQED\endtrivlist\@endpefalse - } -} -% \end{macrocode} -% -% \subsubsection{\pkg{algorithm2e} 宏包} -% -% \begin{macrocode} -\PassOptionsToPackage{algochapter}{algorithm2e} -\sjtu@atendpackage{algorithm2e}{ - \SetAlgorithmName{\sjtu@label@algorithm}% - {\sjtu@label@algorithm}% - {\sjtu@label@listalgorithm} - \SetAlgoCaptionSeparator{~} - \newcommand{\cftalgpresnum}{\sjtu@label@algorithm~} - \AtEndPreamble{% - \newlength{\cftalgindent} - \setlength{\cftalgindent}{1.5em} - \newlength{\cftalgnumwidth} - \setlength{\cftalgnumwidth}{2.3em} - \newlength{\sjtu@cftalgnumwidth@tmp} - \settowidth{\sjtu@cftalgnumwidth@tmp}{\cftalgpresnum} - \addtolength{\cftalgnumwidth}{\sjtu@cftalgnumwidth@tmp} - } - \renewcommand*{\l@algocf}{% - \let\@cftbsnum \cftalgpresnum - \@dottedtocline{1}{\cftalgindent}{\cftalgnumwidth} - } - \renewcommand{\listofalgorithms}{% - \cleardoublepage% - \pdfbookmark[0]{\listalgorithmcfname}{loa}% - \chapter*{\listalgorithmcfname}% - \@mkboth{\listalgorithmcfname}{\listalgorithmcfname}% - \@starttoc{loa} - } - \AtBeginDocument{% - \renewcommand{\thealgocf}{\thechapter--\@arabic\c@algocf} - } -} -% \end{macrocode} -% -% \subsubsection{\pkg{algorithm} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{algorithm}{ - \RequirePackage{algorithmicx, algpseudocode} - \floatname{algorithm}{\sjtu@label@algorithm} - \@addtoreset{algorithm}{chapter} - \patchcmd\@chapter% - {\if@twocolumn} - {\addtocontents{loa}{\protect\addvspace{10\p@}}% - \if@twocolumn} - {}{} - \renewcommand{\listalgorithmname}{\sjtu@label@listalgorithm} - \newcommand{\cftalgpresnum}{\sjtu@label@algorithm~} - \AtEndPreamble{% - \newlength{\cftalgindent} - \setlength{\cftalgindent}{1.5em} - \newlength{\cftalgnumwidth} - \setlength{\cftalgnumwidth}{2.3em} - \newlength{\sjtu@cftalgnumwidth@tmp} - \settowidth{\sjtu@cftalgnumwidth@tmp}{\cftalgpresnum} - \addtolength{\cftalgnumwidth}{\sjtu@cftalgnumwidth@tmp} - } - \newcommand*{\l@algorithm}{% - \let\@cftbsnum \cftalgpresnum - \@dottedtocline{1}{\cftalgindent}{\cftalgnumwidth} - } - \renewcommand{\listofalgorithms}{% - \cleardoublepage% - \pdfbookmark[0]{\listalgorithmname}{loa}% - \chapter*{\listalgorithmname}% - \@mkboth{\listalgorithmname}{\listalgorithmname}% - \@starttoc{loa} - } - \AtBeginDocument{% - \renewcommand{\thealgorithm}{\thechapter--\arabic{algorithm}} - } -} -% \end{macrocode} -% -% \subsubsection{\pkg{listings} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{listings}{ - \lstdefinestyle{lstStyleCode}{ - aboveskip=\medskipamount, - belowskip=\medskipamount, - basicstyle=\footnotesize\ttfamily, - commentstyle=\slshape\color{black!60}, - stringstyle=\color{green!40!black!100}, - keywordstyle=\bfseries\color{blue!50!black}, - extendedchars=false, - upquote=true, - tabsize=2, - showstringspaces=false, - xleftmargin=1em, - xrightmargin=1em, - breaklines=true, - breakindent=2em, - framexleftmargin=1em, - framexrightmargin=1em, - backgroundcolor=\color{gray!10}, - columns=flexible, - keepspaces=true, - texcl=true, - mathescape=true - } - \lstnewenvironment{codeblock}[1][] - {\lstset{style=lstStyleCode,#1}}{} -} -% \end{macrocode} -% -% \subsubsection{\pkg{tikz} 宏包} -% -% \begin{macrocode} -\sjtu@atendpackage{tikz}{ - \usetikzlibrary{shapes.geometric, arrows} - \tikzstyle{startstop} = [ - rectangle, - rounded corners, - minimum width=2cm, - minimum height=1cm, - text centered, - draw=black - ] - \tikzstyle{io} = [ - trapezium, - trapezium left angle=75, - trapezium right angle=105, - minimum width=1cm, - minimum height=1cm, - text centered, - draw=black - ] - \tikzstyle{process} = [ - rectangle, - minimum width=2cm, - minimum height=1cm, - text centered, - draw=black - ] - \tikzstyle{decision} = [ - diamond, - minimum width=2cm, - minimum height=1cm, - text centered, - draw=black] - \tikzstyle{arrow} = [thick, ->, >=stealth] -} -% -% \end{macrocode} -% -% \iffalse -% \begin{macrocode} -%<*document> -\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ltxdoc}} -\PassOptionsToClass{a4paper}{ltxdoc} -\ProcessOptions -\LoadClass{ltxdoc} -\RequirePackage{expl3} -\RequirePackage[UTF8, scheme=chinese]{ctex} -\RequirePackage{booktabs} -\RequirePackage{caption} -\RequirePackage{geometry} -\RequirePackage{graphicx} -\RequirePackage{hologo} -\RequirePackage{listings} -\RequirePackage{newpxtext} -\RequirePackage{newpxmath} -\RequirePackage{xcolor} -\RequirePackage{hypdoc} -\geometry{ - vmargin = 25mm, - hmargin = {40mm, 20mm}, - headsep = 3mm -} -\ctexset{ - abstractname = 简介, -} -\hypersetup{ - allcolors = blue, - bookmarksnumbered = true, - bookmarksopen = true, -} -\AtEndOfClass{\sloppy} -\definecolor{sjtublue}{cmyk}{1,0.8,0,0} -\lstdefinestyle{lstStyleBase}{ - basicstyle = \footnotesize\ttfamily, - commentstyle = \slshape\color{black!60}, - stringstyle = \color{green!40!black!100}, - keywordstyle = \bfseries\color{blue!50!black}, - backgroundcolor = \color{gray!10}, - gobble = 2, % 重要!否则会生成注释符号"%" - tabsize = 2, - xleftmargin = 1em, - xrightmargin = 1em, - framexleftmargin = 1em, - framexrightmargin = 1em -} -\lstdefinestyle{lstStyleShell}{ - style=lstStyleBase, - language=bash -} -\lstdefinestyle{lstStyleLaTeX}{ - style=lstStyleBase, - language=[LaTeX]TeX -} -\newcommand\shellcmd[1]{\colorbox{\color{gray!10}}{\lstinline[style=lstStyleShell]|#1|}} -\lstnewenvironment{shell}{\lstset{style=lstStyleShell}}{} -\lstnewenvironment{latex}{\lstset{style=lstStyleLaTeX}}{} -\newcommand{\note}[1]{{% -\color{magenta}{\noindent\bfseries 说明:}\emph{#1}}} -\def\TeX{\hologo{TeX}} -\def\TeXLive{\TeX\ Live} -\def\macTeX{Mac\TeX{}} -\def\LaTeX{\hologo{LaTeX}} -\def\BibLaTeX{\textsc{Bib}\LaTeX} -\def\CJKLaTeX{CJK--\LaTeX} -\def\XeTeX{\hologo{XeTeX}} -\def\XeLaTeX{\hologo{XeLaTeX}} -\DeclareRobustCommand\file{\nolinkurl} -\DeclareRobustCommand\env{\texttt} -\DeclareRobustCommand\pkg{\textsf} -\DeclareRobustCommand\cls{\textsf} -\DeclareRobustCommand\opt{\texttt} -\def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters - \Describe@Option} -\def\Describe@Option#1{\endgroup - \marginpar{\raggedleft\PrintDescribeOption{#1}}% - \SpecialEnvIndex{#1}\@esphack\ignorespaces} -\@ifundefined{PrintDescribeOption} - {\def\PrintDescribeOption#1{\strut \MacroFont #1\ }}{} -\renewcommand\glossaryname{版本历史} -\GlossaryPrologue{\section*{\glossaryname}} -\ExplSyntaxOn -\DeclareDocumentCommand \StopSpecialIndexModule { } - { \cs_set_eq:NN \__codedoc_special_index_module:nnnnN \use_none:nnnnn } -\cs_new_eq:NN \__sjtudoc_ltx_changes:nnn \changes@ -\cs_set_protected:Npn \changes@ #1#2 - { - \tl_if_empty:nTF {#1} - { \__sjtudoc_ltx_changes:nnn } - { \__sjtudoc_version_zfill:wnnn #1 \q_stop } - {#1} {#2} - } -\cs_new_protected:Npn \__sjtudoc_version_zfill:wnnn #1#2 \q_stop - { - \str_if_eq:nnTF {#1} { v } - { \__sjtudoc_version_zfill:nnnn {#2} } - { \__sjtudoc_ltx_changes:nnn } - } -\cs_new_protected:Npn \__sjtudoc_version_zfill:nnnn #1#2 - { - \tl_clear:N \l__sjtudoc_tmp_tl - \int_zero:N \l_tmpa_int - \seq_set_split:Nnn \l_tmpa_seq { . } {#1} - \seq_map_function:NN \l_tmpa_seq \__sjtudoc_version_zfill:n - \int_compare:nNnF \l_tmpa_int > 2 - { - \tl_put_right:Nx \l__sjtudoc_tmp_tl - { \prg_replicate:nn { 3 - \l_tmpa_int } { 00000 } } - } - \__sjtudoc_ltx_changes:nnn { \l__sjtudoc_tmp_tl \actualchar #2 } - } -\tl_new:N \l__sjtudoc_tmp_tl -\cs_new_protected:Npn \__sjtudoc_version_zfill:n #1 - { - \int_incr:N \l_tmpa_int - \tl_put_right:Nx \l__sjtudoc_tmp_tl - { - \prg_replicate:nn - { \int_max:nn { 0 } { 5 - \tl_count:n {#1} } } { 0 } - \exp_not:n {#1} - } - } -\ExplSyntaxOff -\renewcommand\indexname{命令索引} -\IndexPrologue{% - \section*{\indexname} - \textit{意大利体的数字表示描述对应索引项的页码;% - 带下划线的数字表示定义对应索引项的代码行号;% - 罗马字体的数字表示使用对应索引项的代码行号。}% -} -% -% \end{macrocode} -% \fi -% -% \Finale -% -\endinput diff --git a/sample/tex/abstract.tex b/tex/abstract.tex similarity index 100% rename from sample/tex/abstract.tex rename to tex/abstract.tex diff --git a/sample/tex/acknowledgements.tex b/tex/acknowledgements.tex similarity index 100% rename from sample/tex/acknowledgements.tex rename to tex/acknowledgements.tex diff --git a/sample/tex/app_flow_chart.tex b/tex/app_flow_chart.tex similarity index 100% rename from sample/tex/app_flow_chart.tex rename to tex/app_flow_chart.tex diff --git a/sample/tex/app_maxwell_equations.tex b/tex/app_maxwell_equations.tex similarity index 100% rename from sample/tex/app_maxwell_equations.tex rename to tex/app_maxwell_equations.tex diff --git a/sample/tex/end_english_abstract.tex b/tex/end_english_abstract.tex similarity index 100% rename from sample/tex/end_english_abstract.tex rename to tex/end_english_abstract.tex diff --git a/sample/tex/floats.tex b/tex/floats.tex similarity index 100% rename from sample/tex/floats.tex rename to tex/floats.tex diff --git a/sample/tex/info.tex b/tex/info.tex similarity index 100% rename from sample/tex/info.tex rename to tex/info.tex diff --git a/sample/tex/intro.tex b/tex/intro.tex similarity index 100% rename from sample/tex/intro.tex rename to tex/intro.tex diff --git a/sample/tex/math_and_citations.tex b/tex/math_and_citations.tex similarity index 100% rename from sample/tex/math_and_citations.tex rename to tex/math_and_citations.tex diff --git a/sample/tex/nomenclature.tex b/tex/nomenclature.tex similarity index 100% rename from sample/tex/nomenclature.tex rename to tex/nomenclature.tex diff --git a/sample/tex/patents.tex b/tex/patents.tex similarity index 100% rename from sample/tex/patents.tex rename to tex/patents.tex diff --git a/sample/tex/projects.tex b/tex/projects.tex similarity index 100% rename from sample/tex/projects.tex rename to tex/projects.tex diff --git a/sample/tex/publications.tex b/tex/publications.tex similarity index 100% rename from sample/tex/publications.tex rename to tex/publications.tex diff --git a/sample/tex/resume.tex b/tex/resume.tex similarity index 100% rename from sample/tex/resume.tex rename to tex/resume.tex diff --git a/sample/tex/summary.tex b/tex/summary.tex similarity index 100% rename from sample/tex/summary.tex rename to tex/summary.tex diff --git a/sample/thesis.tex b/thesis.tex similarity index 100% rename from sample/thesis.tex rename to thesis.tex